Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-07

getting UTC time

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd

Is there an easy (or elegant) cross platform way of getting the current time in UTC that works on all platforms? I did some google search and there it seems some people have made themselves some more or less complicated functions for this purpose but they all use either unix and baseunix or they use windows.

There must be a simple function in the RTL to get the current time (in UTC) that works on all platforms, I am sure I must be missing something, such a function surely exists in a modern runtime library in the year 2011, doesn't it?

Bernd

Reply by email

Martin Schreiber
to Bernd
Bernd wrote
Is there an easy (or elegant) cross platform way of getting the current time in UTC that works on all platforms?

MSEgui has nowutc() in lib/common/kernel/msesys.pas. It calls platformdependent sys_getutctime() which is implemented for Linux and Windows.

Martin

Reply by email

Mark Morgan Lloyd
to Bernd: Is there an easy (or elegant) cross platform way of getting the current time in UTC that…
Bernd wrote 10 lines
Is there an easy (or elegant) cross platform way of getting the current time in UTC that works on all platforms? I did some google search and there it seems some people have made themselves some more or less complicated functions for this purpose but they all use either unix and baseunix or they use windows. There must be a simple function in the RTL to get the current time (in UTC) that works on all platforms, I am sure I must be missing something, such a function surely exists in a modern runtime library in the year 2011, doesn't it?

I think the problem is knowing whether the clock on the local computer has been set to UTC, or to a local timezone. Also- in the general case- knowing that it's not been set to "correct" for daylight saving at the hardware level.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email