Results 1 to 12 of 12

Thread: GetSystemTime

  1. #1
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default GetSystemTime

    What time exactly is this returning?

    I'm running XP with timezone set to Atlantic (which is on daylight savings atm) so UTC-3...and it is currently 8:45pm local time (11:45pm utc).

    I would expect this code:
    Simba Code:
    writeln(MsToTime(GetSystemTime, TIME_BARE));
    to return one of the following:
    20:45:00 or 08:45:00 (local time)
    23:45:00 or 11:45:00 (utc time)

    Instead I get:
    01:34:33
    What am I missing here?
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  2. #2
    Join Date
    May 2007
    Location
    Sydney, Australia (Faggot Region)
    Posts
    1,465
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    Simba Code:
    Writeln(thetime)


  3. #3
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Interesting. Returns the correct time, just not formatted the way I want. Guess you can't have everything...
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  4. #4
    Join Date
    May 2007
    Location
    Sydney, Australia (Faggot Region)
    Posts
    1,465
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    this is what it does

    Simba Code:
    {*******************************************************************************
    function TheTime : string;
    By: RsN (fixed by Ron)
    Description: Returns current time as a string
    *******************************************************************************}

    function TheTime: string;
    var
      Hour, Mins, Sec, MSec: Word;
      PAM: string;
    begin
      DecodeTime(Now, Hour, Mins, Sec, MSec);
      PAM := 'AM';
      if (Hour > 12) then
      begin
        Hour := Hour - 12;
        PAM := 'PM';
      end else if (Hour = 12) then
        PAM := 'PM'
      else if (Hour = 0) then
        Hour := 12;
      Result := (Padz(IntToStr(Hour), 2) + ':' + Padz(IntToStr(Mins), 2) + ':' + Padz(IntToStr(Sec), 2) + ' ' + PAM);
    end;


  5. #5
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    GetSystemTime returns the amount of time your computer has been active iirc

  6. #6
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    No, GetSystemTime returns the time since the epoch (well, at least for Unix. Not sure for Windows).

  7. #7
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    No, GetSystemTime returns the time since the epoch (well, at least for Unix. Not sure for Windows).
    I guess that is what I was asking: what is it returning (on Windows)?
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  8. #8
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Windows NT counts the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in the proleptic Gregorian calendar, but returns the current time to the nearest millisecond.

  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    https://github.com/MerlijnWajer/Simb...tedmethods.inc

    -> calls ps_GetTickCount()

    Which returns: https://github.com/MerlijnWajer/Simb...other.inc#L285

    GetTickCount.

    MSDN + GetTickCount: http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    Which is: The return value is the number of milliseconds that have elapsed since the system was started.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #10
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Huh. The more you know.

  11. #11
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Gosh I feel all edjamacated now knowing all that. Thanks for the info.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  12. #12
    Join Date
    May 2008
    Location
    Canada
    Posts
    665
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Bixby Sayz View Post
    Interesting. Returns the correct time, just not formatted the way I want. Guess you can't have everything...
    Old post I was digging through, I modified this little snippet to talk nicely with our programs

    Code:
    program new;
    
    function TheTimeResult: array of Integer;
    var
      Hour, Mins, Sec, MSec: Word;
    begin
      DecodeTime(Now, Hour, Mins, Sec, MSec);
      if (Hour > 12) then
      begin
        Hour := Hour - 12;
      end else if  (Hour = 0) then
        Hour := 12;
      Result := [Hour, Mins, Sec];
    end;
    
    var
    tempArr : array of Integer;
    
    begin
      tempArr := TheTimeResult;
      writeln(tempArr[0]);
      writeln(tempArr[1]);
      writeln(tempARr[2]);
    end.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •