PDFium Component Docs

DecodeDate-metodi

Component: TPdf  ·  Unit: PDFium
Muuntaa PDF-päivämäärämuodon DateTime- ja DateTimeOffset-arvoiksi. DateTimeOffset sisältää päivämäärä- ja aikaoffsetin (minuutteina) suhteessa Coordinated Universal Timeen (UTC)

Syntax

function DecodeDate(const Value: string; out DateTime: TDateTime; out DateTimeOffset: Integer): Boolean;

Valuestring. PDF date string in the PDF date format: D:YYYYMMDDHHmmSSOHH'mm' (e.g. "D:20240515120000+08'00'").
DateTimeTDateTime. Output parameter that receives the decoded date and time value.
DateTimeOffsetInteger. Output parameter that receives the UTC offset in minutes. Positive values indicate east of UTC; negative values indicate west.

Return Value

Palauttaa True, jos Value jäsennettiin onnistuneesti kelvolliseksi PDF-päivämäärämerkkijonoksi. Palauttaa False, jos merkkijono on tyhjä, virheellinen tai ei vastaa PDF-päivämäärämuotoa

Description

DecodeDate is a unit-level global function in the PDFium unit. It parses a PDF date string and converts it to a Delphi TDateTime value together with the UTC timezone offset in minutes.

PDF documents store dates in the format D:YYYYMMDDHHmmSSOHH'mm', where O is the relationship to UTC (+, -, or Z). Use this function to decode the raw strings returned by properties such as CreationDate and ModifiedDate.

The DateTimeOffset out parameter contains the signed UTC offset in minutes (for example, UTC+8 gives 480, UTC-5 gives -300). The DateTime out parameter is set to the local time as encoded in the PDF string, not adjusted to UTC.

Example

var
  DT: TDateTime;
  Offset: Integer;
begin
  if DecodeDate(Pdf.CreationDate, DT, Offset) then
  begin
    ShowMessage('Created: ' + DateTimeToStr(DT));
    ShowMessage('UTC offset (minutes): ' + IntToStr(Offset));
  end;
end;

See Also

CreationDate, ModifiedDate