Mark Morgan Lloyd wrote:
I know that this was discussed a couple of months ago, but I had difficulty working out what the consensus was.

i) Is there an FPC function which will get the raw time from the RTC, which on unix systems will usually be UTC (specifically, without a DST correction)?

Discussion was in March. How time flies. Reinier et al. suggested PascalTZ, but in the end I went for a simple function since I'm trying to avoid installing anything special and timezone info will be available from the backend database.

(* This from FPC-Pascal mailing list, 13/02/07. Thanks, Marco. *)
  //
  function utc_now : TDateTime;
  var
    timeval: TTimeVal;
    timezone: PTimeZone;
    a: Double;
  begin
    TimeZone := nil;
    fpGetTimeOfDay (@TimeVal, TimeZone);
    // Convert to milliseconds
    a := (TimeVal.tv_sec * 1000.0) + (TimeVal.tv_usec / 1000.0);
    Result := (a / MSecsPerDay) + UnixDateDelta;
  end;

ii) Are there functions to get "Unix seconds", "Borland seconds" and so on? Preferably without DST correction, or with the correction being extractable?

DateTimeToUnix() from DateUtils. Anything else I can do without.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to