PDFium Delphi Component 文件

DecodeDate 方法

组件: TPdf  ·  单元: PDFium
将 PDF 日期格式转换为 DateTime 和 DateTimeOffset。DateTimeOffset 包含相对于 Coordinated Universal Time (UTC) 的日期/时间偏移量(分钟)。

Syntax

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

Valuestring。PDF 日期格式的 PDF 日期字符串:D:YYYYMMDDHHmmSSOHH'mm'(例如 "D:20240515120000+08'00'")
DateTimeTDateTime。接收解码后的日期和时间值的输出参数
DateTimeOffsetInteger。接收以分钟计的 UTC 偏移量的输出参数。正值表示 UTC 以东;负值表示以西

Return Value

如果 Value 被成功解析为有效的 PDF 日期字符串,则返回 True。如果字符串为空、格式错误或不符合 PDF 日期格式,则返回 False

Description

DecodeDate 是 PDFium 单元中的一个单元级全局函数。它解析 PDF 日期字符串,并将其与以分钟计的 UTC 时区偏移量一起转换为 Delphi TDateTime 值

PDF 文档以 D:YYYYMMDDHHmmSSOHH'mm' 格式存储日期,其中 O 是与 UTC 的关系(+、- 或 Z)。使用此函数解码由 CreationDate 和 ModifiedDate 等属性返回的原始字符串

DateTimeOffset 输出参数包含以分钟计的有符号 UTC 偏移量(例如,UTC+8 为 480,UTC-5 为 -300)。DateTime 输出参数设置为 PDF 字符串中编码的本地时间,不调整为 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