Log in

View Full Version : GetSystemTime



Bixby Sayz
08-28-2011, 11:50 PM
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
08-29-2011, 12:02 AM
Writeln(thetime)

Bixby Sayz
08-29-2011, 12:05 AM
Interesting. Returns the correct time, just not formatted the way I want. Guess you can't have everything...

Simtoon
08-29-2011, 12:14 AM
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_
08-30-2011, 09:24 PM
GetSystemTime returns the amount of time your computer has been active iirc

i luffs yeww
08-30-2011, 09:26 PM
No, GetSystemTime returns the time since the epoch (well, at least for Unix. Not sure for Windows).

Bixby Sayz
08-30-2011, 11:20 PM
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
08-30-2011, 11:26 PM
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?
08-30-2011, 11:29 PM
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
08-30-2011, 11:31 PM
Huh. The more you know.

Bixby Sayz
08-30-2011, 11:47 PM
Gosh I feel all edjamacated now knowing all that. Thanks for the info.

mrpickle
09-21-2015, 04:13 PM
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 :)


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.