SRL Archive - Help

GetSystemTime


Bixby Sayz

2011-08-28 19:50:05

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:
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?

Simtoon

2011-08-28 20:02:17


Writeln(thetime)

Bixby Sayz

2011-08-28 20:05:55

Interesting. Returns the correct time, just not formatted the way I want. Guess you can't have everything…

Simtoon

2011-08-28 20:14:36

this is what it does


{*******************************************************************************
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;

Echo_

2011-08-30 17:24:14

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

i luffs yeww

2011-08-30 17:26:20

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

Bixby Sayz

2011-08-30 19:20:57

From: i luffs yeww
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)?

i luffs yeww

2011-08-30 19:26:23

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.

Wizzup?

2011-08-30 19:29:29

https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLAddon/PSInc/psexportedmethods.inc

-> calls ps_GetTickCount()

Which returns: https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLAddon/PSInc/Wrappers/other.inc#L285

GetTickCount.

MSDN + GetTickCount: http://msdn.microsoft.com/en-us/library/ms724408%28v=vs.85%29.aspx

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

i luffs yeww

2011-08-30 19:31:42

Huh. The more you know.

Bixby Sayz

2011-08-30 19:47:21

Gosh I feel all edjamacated now knowing all that. Thanks for the info.