Системное время в Builder c++

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by Dencity, 22 Apr 2008.

  1. Dencity

    Dencity Elder - Старейшина

    Joined:
    28 Feb 2008
    Messages:
    14
    Likes Received:
    8
    Reputations:
    0
    Привет всем...Я вот пользуюсь для получения системного времени в Билдер с++ такой функцией
    AnsiString SystemTime()
    {
    time_t rawtime;
    struct tm * timeinfo;
    AnsiString st_time="",res_ult="";
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    st_time= (AnsiString)asctime (timeinfo);
    int i;
    for (i=1;i<st_time.Length();i++)
    res_ult=res_ult+st_time;
    return res_ult;
    }
    и она выдает результат строкой :
    Thu Feb 21 23:10:28 2008

    Но мне надо чтоб ответ был исключительно в числах тоесть чтоб месяц и день были числами,таким образом легко преобразовать всю дату в сплошное число! В Линухе время задается сплошным числом равным количеством секунд от создания Юникс...но в Винде как подобное осуществить я не знаю...помогите плыз.
     
  2. Dencity

    Dencity Elder - Старейшина

    Joined:
    28 Feb 2008
    Messages:
    14
    Likes Received:
    8
    Reputations:
    0
    Возможно есть какие то форматы вывода времени?но как их задавать...вобщем проблема:(
     
  3. Forcer

    Forcer Elder - Старейшина

    Joined:
    12 Apr 2007
    Messages:
    321
    Likes Received:
    98
    Reputations:
    12
    есть функция time(). хедер - time.h
     
    1 person likes this.
  4. x0man

    x0man Elder - Старейшина

    Joined:
    24 Feb 2006
    Messages:
    33
    Likes Received:
    13
    Reputations:
    0
    Code:
    The GetSystemTime function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC). 
    
    VOID GetSystemTime(
        LPSYSTEMTIME lpSystemTime 	// address of system time structure  
       );	
     
    Parameters
    
    lpSystemTime
    Points to a SYSTEMTIME structure to receive the current system date and time. 
    
    Return Values
    This function does not return a value. 
    
    See Also
    GetLocalTime, GetSystemTimeAdjustment, SetSystemTime, SYSTEMTIME 
    
     
    1 person likes this.
  5. krypt3r

    krypt3r Elder - Старейшина

    Joined:
    27 Apr 2007
    Messages:
    1,507
    Likes Received:
    389
    Reputations:
    101
    GetSystemTime, GetLocalTime, GetTickCount