[]
Represents a PDF DateTime type.
public struct PdfDateTime : IEquatable<PdfDateTime>
The PDF Specification does not define a special type for DateTime values, such values are stored as strings in a special format, similar to (D:YYYYMMDDHHmmSSOHH'mm'), see the spec for details (PDF 1.7 chapter 3.8.3).
But there are many PDF documents in which DateTime strings are specified in some custom format, for example using a regional format. GcPdf uses this struct when processing such values. Where possible, the value is converted to DateTimeOffset, otherwise it preserves the original string value.
Initializes a new instance of the PdfDateTime struct using a IPdfString. The passed string is converted to DateTimeOffset if possible.
public PdfDateTime(IPdfString value)
value
IPdfStringThe IPdfString representing a date time value.
Initializes a new instance of the PdfDateTime struct using a DateTime value.
public PdfDateTime(DateTime value)
Initializes a new instance of the PdfDateTime struct using a string. The passed string is converted to DateTimeOffset if possible.
public PdfDateTime(string value)
value
stringThe string representing a date time value.
Gets the DateTimeOffset value defined by this PdfDateTime. Throws an exception if this PdfDateTime is represented by an unparsed string.
public DateTimeOffset DateTimeOffset { get; }
Gets the DateTime value representing local time. Throws an exception if this PdfDateTime is represented by an unparsed string.
public DateTime DateTimeValue { get; }
Gets a value indicating whether this PdfDateTime struct contains a string value which cannot be converted to DateTime.
public bool IsString { get; }
Gets the IPdfString representing the value of this PdfDateTime.
public IPdfString Value { get; }
Converts a DateTime value to a string in PDF format as described in PDF 1.7 specification chapter 3.8.3.
public static string DateTimeToPdfString(DateTime value)
Returns string with formatted datetime.
Converts a DateTimeOffset value to a string in PDF format as described in PDF 1.7 specification chapter 3.8.3.
public static string DateTimeToPdfString(DateTimeOffset value)
value
DateTimeOffsetThe DateTime value.
Returns string with formatted datetime.
Checks whether this PdfDateTime is equal to another PdfDateTime.
public bool Equals(PdfDateTime other)
other
PdfDateTimeThe PdfDateTime value to compare to.
True if values are equal, false otherwise.
public override bool Equals(object obj)
obj
objectpublic override int GetHashCode()
public override string ToString()
Converts this PdfDateTime to string, using a specified format if the current struct holds a DateTime value.
public string ToString(string dateTimeFormat)
dateTimeFormat
stringThe date time format.
Tries to convert a string to DateTimeOffset. See PDF 1.7 specification chapter 3.8.3.
public static bool TryParse(string s, out DateTimeOffset value)
s
stringThe string in the format D:YYYYMMDDHHmmSSOHH'mm'.
value
DateTimeOffsetOUT: The parsed DateTimeOffset value.
True if conversion succeed, false otherwise.
The equality operator.
public static bool operator ==(PdfDateTime v1, PdfDateTime v2)
v1
PdfDateTimev2
PdfDateTimeConverts a DateTime value to PdfDateTime.
public static implicit operator PdfDateTime(DateTime value)
value
DateTimeThe inequality operator.
public static bool operator !=(PdfDateTime v1, PdfDateTime v2)
v1
PdfDateTimev2
PdfDateTime