<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 20 July 2016 at 15:52, Denis Kozlov <span dir="ltr"><<a href="mailto:dezlov@gmail.com" target="_blank">dezlov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br><div>So, below is a tidy cross-platform implementation of NowUTC:<br></div></div></div></div></blockquote><div><br></div><div>Oops, forgot the milliseconds, here it is:<br><span style="font-family:monospace,monospace"><br>function NowUTC: TDateTime;<br>{$ifdef WINDOWS}<br>var<br>  SystemTime: TSystemTime;<br>begin<br>  Windows.GetSystemTime(SystemTime);<br>  Result := SystemTimeToDateTime(SystemTime);<br>end;<br>{$else}<br>{$ifdef UNIX}<br>var<br>  tp: timeval;<br>begin<br>  fpgettimeofday(@tp,nil);<br>  Result := UnixToDateTime(tp.tv_sec);<br>  Result := IncMilliSecond(Result, tp.tv_usec div 1000);<br>end;<br>{$else}<br>begin<br>  // WARNING: Suffers from a race condition!<br>  Result := LocalTimeToUniversal(Now);<br>end;<br>{$endif}<br>{$endif}</span><br></div></div></div></div>