[]
        
(Showing Draft Content)

GrapeCity.Documents.Pdf.PdfDateTime

Struct PdfDateTime

Namespace
GrapeCity.Documents.Pdf
Assembly
GcDocs.Pdf.dll

Represents a PDF DateTime type.

public struct PdfDateTime : IEquatable<PdfDateTime>
Implements
Inherited Members

Remarks

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.

Constructors

PdfDateTime(IPdfString)

Initializes a new instance of the PdfDateTime struct using a IPdfString. The passed string is converted to DateTimeOffset if possible.

public PdfDateTime(IPdfString value)

Parameters

value IPdfString

The IPdfString representing a date time value.

PdfDateTime(DateTime)

Initializes a new instance of the PdfDateTime struct using a DateTime value.

public PdfDateTime(DateTime value)

Parameters

value DateTime

The DateTime value.

PdfDateTime(string)

Initializes a new instance of the PdfDateTime struct using a string. The passed string is converted to DateTimeOffset if possible.

public PdfDateTime(string value)

Parameters

value string

The string representing a date time value.

Properties

DateTimeOffset

Gets the DateTimeOffset value defined by this PdfDateTime. Throws an exception if this PdfDateTime is represented by an unparsed string.

public DateTimeOffset DateTimeOffset { get; }

Property Value

DateTimeOffset

DateTimeValue

Gets the DateTime value representing local time. Throws an exception if this PdfDateTime is represented by an unparsed string.

public DateTime DateTimeValue { get; }

Property Value

DateTime

IsString

Gets a value indicating whether this PdfDateTime struct contains a string value which cannot be converted to DateTime.

public bool IsString { get; }

Property Value

bool

Value

Gets the IPdfString representing the value of this PdfDateTime.

public IPdfString Value { get; }

Property Value

IPdfString

Methods

DateTimeToPdfString(DateTime)

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)

Parameters

value DateTime

The DateTime value.

Returns

string

Returns string with formatted datetime.

DateTimeToPdfString(DateTimeOffset)

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)

Parameters

value DateTimeOffset

The DateTime value.

Returns

string

Returns string with formatted datetime.

Equals(PdfDateTime)

Checks whether this PdfDateTime is equal to another PdfDateTime.

public bool Equals(PdfDateTime other)

Parameters

other PdfDateTime

The PdfDateTime value to compare to.

Returns

bool

True if values are equal, false otherwise.

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

ToString(string)

Converts this PdfDateTime to string, using a specified format if the current struct holds a DateTime value.

public string ToString(string dateTimeFormat)

Parameters

dateTimeFormat string

The date time format.

Returns

string

TryParse(string, out DateTimeOffset)

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)

Parameters

s string

The string in the format D:YYYYMMDDHHmmSSOHH'mm'.

value DateTimeOffset

OUT: The parsed DateTimeOffset value.

Returns

bool

True if conversion succeed, false otherwise.

Operators

operator ==(PdfDateTime, PdfDateTime)

The equality operator.

public static bool operator ==(PdfDateTime v1, PdfDateTime v2)

Parameters

v1 PdfDateTime
v2 PdfDateTime

Returns

bool

implicit operator PdfDateTime(DateTime)

Converts a DateTime value to PdfDateTime.

public static implicit operator PdfDateTime(DateTime value)

Parameters

value DateTime

Returns

PdfDateTime

operator !=(PdfDateTime, PdfDateTime)

The inequality operator.

public static bool operator !=(PdfDateTime v1, PdfDateTime v2)

Parameters

v1 PdfDateTime
v2 PdfDateTime

Returns

bool