<commit_before>/*************************************************************************
 *                                                                       *
 *  I|*j^3Cl|a   "+!*%                  qt          Nd   gW              *
 *  l]{y+l?MM*  !#Wla\NNP               NW          MM   I|              *
 *        PW    ?E|    tWg              Wg  sC!     AW           ~@v~    *
 *       NC     ?M!    yN|  WW     MK   MW@K1Y%M@   RM   #Q    QP@tim    *
 *     CM|      |WQCljAE|   MD     Mg   RN     cM~  NM   WQ   MQ         *
 *    #M        aQ?         MW     M3   Mg      Q(  HQ   YR  IM|         *
 *   Dq         {Ql         MH    iMX   Mg     MM   QP   QM   Eg         *
 * !EWNaPRag2$  +M"          $WNaHaN%   MQE$%EXW    QQ   CM    %M%a$D    *
 *                                                                       *
 *               Website: https://github.com/zpublic/zpublic             *
 *                                                                       *
 ************************************************************************/

/**
 * @file
 * @brief ʱ
 */


#pragma once
#include "win_utils_header.h"

namespace zl
{
namespace WinUtils
{
    /**
     * @brief ʱز
     */
    class ZLTime
    {
    public:
        /**
         * @brief __time64_tFileTimeת
         * @param[in] tm __time64_t
         * @return ɹFILETIME
         */
        static FILETIME Time642FileTime(const __time64_t& tm)
        {
            FILETIME ft;
            LONGLONG ll;
            ll = tm*10000000 + 116444736000000000;
            ft.dwLowDateTime  = (DWORD)ll;
            ft.dwHighDateTime = (DWORD)(ll >> 32);
            return ft;
        }
        /**
         * @brief FileTime__time64_tת
         * @param[in] pft FILETIMEṹָ
         * @return __time64_t
         */
        static __time64_t FileTime2Time64(const FILETIME& pft)
        {
            __time64_t cTime = pft.dwHighDateTime;
            cTime = (cTime<<32) + pft.dwLowDateTime;  
            return ((cTime - 116444736000000000)/10000000);
        }

        static __time64_t SystemTime2Time64(const SYSTEMTIME& st)
        {
            FILETIME ft;
            SystemTime2FileTime(st, ft);
            return FileTime2Time64(ft);
        }

        static BOOL SystemTime2FileTime(const SYSTEMTIME& syst, FILETIME& filet)
        {
            return ::SystemTimeToFileTime(&syst, &filet);
        }

        static BOOL FileTime2SystemTime(const FILETIME& filet, SYSTEMTIME& syst)
        {
            return ::FileTimeToSystemTime(&filet, &syst);
        }

        static SYSTEMTIME GetLocalTime()
        {
            SYSTEMTIME st;
            ::GetLocalTime(&st);
            return st;
        }

        static SYSTEMTIME GetSystemTime()
        {
            SYSTEMTIME st;
            ::GetSystemTime(&st);
            return st;
        }
        /**
         * @brief TimeInterval
         * @param[in]  llTimeBegin    ʼʱ
         * @param[out] dfTimeInterval TimeInterval
         * @return ɹTRUEʧܷFALSE
         */
        static BOOL Calc( LARGE_INTEGER& llTimeBegin, double& dfTimeInterval )
        {
            LARGE_INTEGER freq = {0};
            LARGE_INTEGER timeEnd = {0};
            if (llTimeBegin.QuadPart == 0
                && ::QueryPerformanceFrequency(&freq)
                && ::QueryPerformanceCounter(&timeEnd))
            {
                dfTimeInterval = double(timeEnd.QuadPart - llTimeBegin.QuadPart) / freq.QuadPart * 1000.0;
                return TRUE;
            }
            return FALSE;
        }

        static BOOL GetTime( LARGE_INTEGER& llCurrentTime )
        {
            return ::QueryPerformanceCounter(&llCurrentTime);
        }
    };

}
}
<commit_msg>* fix 计算TimeInterval bug<commit_after>/*************************************************************************
 *                                                                       *
 *  I|*j^3Cl|a   "+!*%                  qt          Nd   gW              *
 *  l]{y+l?MM*  !#Wla\NNP               NW          MM   I|              *
 *        PW    ?E|    tWg              Wg  sC!     AW           ~@v~    *
 *       NC     ?M!    yN|  WW     MK   MW@K1Y%M@   RM   #Q    QP@tim    *
 *     CM|      |WQCljAE|   MD     Mg   RN     cM~  NM   WQ   MQ         *
 *    #M        aQ?         MW     M3   Mg      Q(  HQ   YR  IM|         *
 *   Dq         {Ql         MH    iMX   Mg     MM   QP   QM   Eg         *
 * !EWNaPRag2$  +M"          $WNaHaN%   MQE$%EXW    QQ   CM    %M%a$D    *
 *                                                                       *
 *               Website: https://github.com/zpublic/zpublic             *
 *                                                                       *
 ************************************************************************/

/**
 * @file
 * @brief ʱ
 */


#pragma once
#include "win_utils_header.h"

namespace zl
{
namespace WinUtils
{
    /**
     * @brief ʱز
     */
    class ZLTime
    {
    public:
        /**
         * @brief __time64_tFileTimeת
         * @param[in] tm __time64_t
         * @return ɹFILETIME
         */
        static FILETIME Time642FileTime(const __time64_t& tm)
        {
            FILETIME ft;
            LONGLONG ll;
            ll = tm*10000000 + 116444736000000000;
            ft.dwLowDateTime  = (DWORD)ll;
            ft.dwHighDateTime = (DWORD)(ll >> 32);
            return ft;
        }
        /**
         * @brief FileTime__time64_tת
         * @param[in] pft FILETIMEṹָ
         * @return __time64_t
         */
        static __time64_t FileTime2Time64(const FILETIME& pft)
        {
            __time64_t cTime = pft.dwHighDateTime;
            cTime = (cTime<<32) + pft.dwLowDateTime;  
            return ((cTime - 116444736000000000)/10000000);
        }

        static __time64_t SystemTime2Time64(const SYSTEMTIME& st)
        {
            FILETIME ft;
            SystemTime2FileTime(st, ft);
            return FileTime2Time64(ft);
        }

        static BOOL SystemTime2FileTime(const SYSTEMTIME& syst, FILETIME& filet)
        {
            return ::SystemTimeToFileTime(&syst, &filet);
        }

        static BOOL FileTime2SystemTime(const FILETIME& filet, SYSTEMTIME& syst)
        {
            return ::FileTimeToSystemTime(&filet, &syst);
        }

        static SYSTEMTIME GetLocalTime()
        {
            SYSTEMTIME st;
            ::GetLocalTime(&st);
            return st;
        }

        static SYSTEMTIME GetSystemTime()
        {
            SYSTEMTIME st;
            ::GetSystemTime(&st);
            return st;
        }
        /**
         * @brief TimeInterval
         * @param[in]  llTimeBegin    ʼʱ
         * @param[out] dfTimeInterval TimeInterval
         * @return ɹTRUEʧܷFALSE
         */
        static BOOL Calc( LARGE_INTEGER& llTimeBegin, double& dfTimeInterval )
        {
            LARGE_INTEGER freq = {0};
            LARGE_INTEGER timeEnd = {0};
            if (llTimeBegin.QuadPart != 0
                && ::QueryPerformanceFrequency(&freq)
                && ::QueryPerformanceCounter(&timeEnd))
            {
                dfTimeInterval = double(timeEnd.QuadPart - llTimeBegin.QuadPart) / freq.QuadPart * 1000.0;
                return TRUE;
            }
            return FALSE;
        }

        static BOOL GetTime( LARGE_INTEGER& llCurrentTime )
        {
            return ::QueryPerformanceCounter(&llCurrentTime);
        }
    };

}
}

{'fraction_non_alphanumeric': 0.12974641084127198, 'fraction_numerical': 0.02656648329531732, 'mean_word_length': 1.2092471843509187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2201763', 'n_tokens_mistral': 2400, 'n_tokens_neox': 2176, 'n_words': 435}