• 获取某个时间的当前毫秒数(相对于格林时间)


    typedef unsigned char BYTE;
    typedef unsigned short WORD;
    
    typedef struct
    {
     WORD wYear;
     BYTE byMonth;
     BYTE byDay;
     BYTE byHour;
     BYTE byMinute;
     BYTE bySecond;
     WORD wMilliSec;
    }SDateTime;
    #define TM_YEAR_BASE 0
    
    
    #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0 ) || (((y) % 400) == 0 && ((y) % 4000) != 0))
    
    /************************************************************************
    *
    *  daysSinceEpoch - calculate number days since ANSI C epoch                 
    * 
    *  The (year + 1)/4 term accounts for leap years, the     
    *  first of which was 1972 & should be added starting '73 
    * 
    * RETURNS:
    * NOMANUAL
    */
    int __daysSinceEpoch_db( int year, /* Years since epoch */int yday  /* days since Jan 1  */)
    {
     if( year >= 0 ) /* 1970 + */
         return ( (365 * year) + (year + 1) / 4  + yday );
     else  /* 1969 - */
         return ( (365 * year) + (year - 2) / 4  + yday );
    }
    
    /************************************************************************
    *
    * julday - calculate Julian Day given year, month, day            
    *              Inputs      : year (years since 1900), month (0 - 11), 
    *             day (1 - 31)  
    *              Comment     : Returns Julian day in range 1:366.  
    *        Unix wants 0:365 
    * RETURNS: Julian day                                            
    * NOMANUAL
    */
    int __julday_db( int yr, /* year */int mon, /* month */int day /* day */)
    {
        static jdays[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
        int leap = 0;
        if (isleap (yr + TM_YEAR_BASE))
    	{
    	 /*
    	  * If it is a leap year, leap only gets set if the day is
    	  * after beginning of March (SPR #4251).
    	  */
    	 if (mon > 1)
    		 leap = 1;
    	}
        return (jdays[mon] + day + leap);
    }
        
    /**********************************************************************
        GetSecondSinceEpoch--Get Seconds since 1970
    */
    int GetSecondSinceEpoch(SDateTime* sDateTime)
    {
        int julday;
        int day;
    
    	if( sDateTime->wYear < 100 )
    	{
    	   sDateTime->wYear += 2000 ;
    	}/*if*/
        julday=__julday_db(sDateTime->wYear,sDateTime->byMonth - 1,sDateTime->byDay );
        
    	day=__daysSinceEpoch_db(sDateTime->wYear-1970,julday);
        return( ( (day*24 + sDateTime->byHour)*60 + sDateTime->byMinute )*60 +sDateTime->bySecond);
    }
    

      

    当你的才华还撑不起你的野心时,那你就应该静下心来学习。
  • 相关阅读:
    day12——Python高阶函数及匿名函数
    day11——Python函数的一般形式、函数的参数
    day10——Python file操作
    day9——Python复习
    day8——Python if,while,for
    day7——Python的帮助
    day6——Python数据类型
    sqlserver执行sql文件命令(sqlcmd)
    数据库快照、游标、锁
    Linux 下根据进程名kill进程
  • 原文地址:https://www.cnblogs.com/aceg/p/4360764.html
Copyright © 2020-2023  润新知