CkDateTime Delphi DLL Reference Documentation

CkDateTime

Current Version: 9.5.0.97

A class for holding a date/time value, and for converting it to from many different formats. The power of this class is that the different date/time formats are implemented across many different operating systems. Many formats specific to Windows are available on Mac OS X, Linux/Unix, etc., and vice-versa. To convert a date/time from one format to another, simply set via one format, and get via another format. This is a freeware class because it is used by many commercial Chilkat components/libs.

Create/Dispose

var
myObject: HCkDateTime;

begin
myObject := CkDateTime_Create();

// ...

CkDateTime_Dispose(myObject);
end;
function CkDateTime_Create: HCkDateTime; stdcall;

Creates an instance of the HCkDateTime object and returns a handle (i.e. a Pointer). The handle is passed in the 1st argument for the functions listed on this page.

procedure CkDateTime_Dispose(handle: HCkDateTime); stdcall;

Objects created by calling CkDateTime_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

Properties

DebugLogFilePath
procedure CkDateTime_getDebugLogFilePath(objHandle: HCkDateTime; outPropVal: HCkString); stdcall;
procedure CkDateTime_putDebugLogFilePath(objHandle: HCkDateTime; newPropVal: PWideChar); stdcall;
function CkDateTime__debugLogFilePath(objHandle: HCkDateTime): PWideChar; stdcall;

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

top
IsDst
function CkDateTime_getIsDst(objHandle: HCkDateTime): Integer; stdcall;

This is the Daylight Saving Time flag. It can have one of three possible values: 1, 0, or -1. It has the value 1 if Daylight Saving Time is in effect, 0 if Daylight Saving Time is not in effect, and -1 if the information is not available.

Note: This is NOT the DST for the current system time. It is the DST that was in effect at the date value contained in this object.

top
LastErrorHtml
procedure CkDateTime_getLastErrorHtml(objHandle: HCkDateTime; outPropVal: HCkString); stdcall;
function CkDateTime__lastErrorHtml(objHandle: HCkDateTime): PWideChar; stdcall;

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastErrorText
procedure CkDateTime_getLastErrorText(objHandle: HCkDateTime; outPropVal: HCkString); stdcall;
function CkDateTime__lastErrorText(objHandle: HCkDateTime): PWideChar; stdcall;

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastErrorXml
procedure CkDateTime_getLastErrorXml(objHandle: HCkDateTime; outPropVal: HCkString); stdcall;
function CkDateTime__lastErrorXml(objHandle: HCkDateTime): PWideChar; stdcall;

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastMethodSuccess
function CkDateTime_getLastMethodSuccess(objHandle: HCkDateTime): wordbool; stdcall;
procedure CkDateTime_putLastMethodSuccess(objHandle: HCkDateTime; newPropVal: wordbool); stdcall;

Indicate whether the last method call succeeded or failed. A value of True indicates success, a value of False indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = True and failure = False.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to True. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

top
UtcOffset
function CkDateTime_getUtcOffset(objHandle: HCkDateTime): Integer; stdcall;

For the current system's timezone, returns the number of seconds offset from UTC for this date/time. The offset includes daylight savings adjustment. Local timezones west of UTC return a negative offset.

top
VerboseLogging
function CkDateTime_getVerboseLogging(objHandle: HCkDateTime): wordbool; stdcall;
procedure CkDateTime_putVerboseLogging(objHandle: HCkDateTime; newPropVal: wordbool); stdcall;

If set to True, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is False. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
procedure CkDateTime_getVersion(objHandle: HCkDateTime; outPropVal: HCkString); stdcall;
function CkDateTime__version(objHandle: HCkDateTime): PWideChar; stdcall;

Version of the component/library, such as "9.5.0.94"

More Information and Examples
top

Methods

AddDays
function CkDateTime_AddDays(objHandle: HCkDateTime;
    numDays: Integer): wordbool; stdcall;

Adds an integer number of days to the date/time. To subtract days, pass a negative integer.

Returns True for success, False for failure.

top
AddSeconds
function CkDateTime_AddSeconds(objHandle: HCkDateTime;
    numSeconds: Integer): wordbool; stdcall;
Introduced in version 9.5.0.65

Adds an integer number of seconds to the date/time. To subtract seconds, pass a negative integer.

Returns True for success, False for failure.

More Information and Examples
top
DeSerialize
procedure CkDateTime_DeSerialize(objHandle: HCkDateTime;
    serializedDateTime: PWideChar) stdcall;

Loads the date/time with a string having the format as produced by the Serialize method, which is a string of SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1/0.

top
DiffSeconds
function CkDateTime_DiffSeconds(objHandle: HCkDateTime;
    dateTimeArg: HCkDateTime): Integer; stdcall;
Introduced in version 9.5.0.65

Returns the difference in seconds between the dateTimeArg and this date/time. The value returned is this object's date/time - dateTimeArg's date/time. For example, if the returned value is positive, then this object's date/time is more recent than dateTimeArg's date/time. If the return value is negative, then this object's date/time is older than dateTimeArg's date/time.

top
ExpiresWithin
function CkDateTime_ExpiresWithin(objHandle: HCkDateTime;
    n: Integer;
    units: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.67

Returns True if the date/time is within n seconds/minutes/hours/days of the current system date/time. Otherwise returns False. The units can be "seconds", "minutes", "hours", or "days" (plural or singular).

top
GetAsDateTimeTicks
function CkDateTime_GetAsDateTimeTicks(objHandle: HCkDateTime;
    bLocal: wordbool): Int64; stdcall;

Returns the date/time as a 64-bit integer .NET DateTime value.

bLocal indicates whether a local or UTC time is returned.

This is a date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.

The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.).

Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the GregorianCalendar calendar (excluding ticks that would be added by leap seconds). For example, a ticks value of 31241376000000000L represents the date, Friday, January 01, 0100 12:00:00 midnight. A DateTime value is always expressed in the context of an explicit or default calendar.

top
GetAsDosDate
function CkDateTime_GetAsDosDate(objHandle: HCkDateTime;
    bLocal: wordbool): LongWord; stdcall;

Returns the date/time as a 32-bit DOS date/time bitmask.

bLocal indicates whether a local or UTC time is returned.

The DOS date/time format is a bitmask:


			   24                16                 8                 0
	    +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
	    |Y|Y|Y|Y|Y|Y|Y|M| |M|M|M|D|D|D|D|D| |h|h|h|h|h|m|m|m| |m|m|m|s|s|s|s|s|
	    +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
	     \___________/\________/\_________/ \________/\____________/\_________/
		 year        month       day      hour       minute        second

The year is stored as an offset from 1980. Seconds are stored in two-second increments. (So if the "second" value is 15, it actually represents 30 seconds.)

top
GetAsFileTime
procedure CkDateTime_GetAsFileTime(objHandle: HCkDateTime;
    bLocal: wordbool;
    fTime: FILETIME &) stdcall;

Returns the date/time in a Windows FILETIME structure.

bLocal indicates whether a local or UTC time is returned.

For non-Windows systems, the FILETIME structure is defined in the FileTime.h header provided in the Chilkat C/C++ libs distribution. The structure is defined as follows:

typedef struct _FILETIME
    {
    unsigned long dwLowDateTime;
    unsigned long dwHighDateTime;
    } 	FILETIME;

top
GetAsIso8601
function CkDateTime_GetAsIso8601(objHandle: HCkDateTime;
    formatStr: PWideChar;
    bLocal: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__getAsIso8601(objHandle: HCkDateTime;
    formatStr: PWideChar;
    bLocal: wordbool): PWideChar; stdcall;
Introduced in version 9.5.0.65

Returns the date/time in a compatible ISO 8601 format according to the format specified in formatStr.. Examples of ISO 8601 formats include the following:

    YYYY-MM-DD

    YYYY-MM-DDThh:mmTZD

    YYYY-MM-DDThh:mm:ssTZD
For the date portion of these formats, YYYY is a four-digit year representation, MM is a two-digit month representation, and DD is a two-digit day representation. For the time portion, hh is the hour representation in 24-hour notation, mm is the two-digit minute representation, and ss is the two-digit second representation. A time designator T separates the date and time portions of the string, while a time zone designator TZD specifies a time zone (UTC).

bLocal indicates whether a local or UTC time is returned.

Note: The bLocal argument is interpreted as the reverse of what is intended . The problem was discovered just after releasing v9.5.0.65. It will be fixed in the next version update.

Returns True for success, False for failure.

More Information and Examples
top
GetAsOleDate
function CkDateTime_GetAsOleDate(objHandle: HCkDateTime;
    bLocal: wordbool): Double; stdcall;

Returns the date/time in a Windows OLE "DATE" format.

bLocal indicates whether a local or UTC time is returned.

The OLE automation date format is a floating point value, counting days since midnight 30 December 1899. Hours and minutes are represented as fractional days.

top
GetAsRfc822
function CkDateTime_GetAsRfc822(objHandle: HCkDateTime;
    bLocal: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__getAsRfc822(objHandle: HCkDateTime;
    bLocal: wordbool): PWideChar; stdcall;

Returns the date/time as an RFC822 formatted string. (An RFC822 format string is what is found in the "Date" header field of an email, such as "Wed, 18 Oct 2017 09:08:21 GMT".)

bLocal indicates whether a local or UTC time is returned.

Returns True for success, False for failure.

top
GetAsTimestamp
function CkDateTime_GetAsTimestamp(objHandle: HCkDateTime;
    bLocal: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__getAsTimestamp(objHandle: HCkDateTime;
    bLocal: wordbool): PWideChar; stdcall;
Introduced in version 9.5.0.58

Returns the date/time as an RFC 3339 formatted string, such as "1990-12-31T23:59:60Z". (This is an ISO 8061 format like the following: YYYY-MM-DDThh:mm:ssTZD)

bLocal indicates whether a local or UTC time is returned.

Returns True for success, False for failure.

top
GetAsUnixTime
function CkDateTime_GetAsUnixTime(objHandle: HCkDateTime;
    bLocal: wordbool): LongWord; stdcall;

Returns the date/time as a 32-bit Unix time.

bLocal indicates whether the date/time returned is local or UTC.

Note: With this format, there is a Y2038 problem that pertains to 32-bit signed integers. There are approx 31.5 million seconds per year. The Unix time is number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). In 2012, it's 42 years since 1/1/1970, so the number of seconds is approx 1.3 billion. A 32-bit signed integer ranges from -2,147,483,648 to 2,147,483,647 Therefore, if a 32-bit signed integer is used, it turns negative in 2038.

The GetAsUnixTime64 and GetAsUnixTimeDbl methods are provided as solutions to the Y2038 problem.

(Note: The ActiveX Chilkat implementation omits methods that use 64-bit integers because there is no means for passing or returning 64-bit integers in ActiveX.)

top
GetAsUnixTime64
function CkDateTime_GetAsUnixTime64(objHandle: HCkDateTime;
    bLocal: wordbool): Int64; stdcall;

The same as GetUnixTime, except returns the date/time as a 64-bit integer.

bLocal indicates whether a local or UTC time is returned.

top
GetAsUnixTimeDbl
function CkDateTime_GetAsUnixTimeDbl(objHandle: HCkDateTime;
    bLocal: wordbool): Double; stdcall;

The same as GetUnixTime, except returns the date/time as a double.

bLocal indicates whether a local or UTC time is returned.

top
GetAsUnixTimeStr
function CkDateTime_GetAsUnixTimeStr(objHandle: HCkDateTime;
    bLocal: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__getAsUnixTimeStr(objHandle: HCkDateTime;
    bLocal: wordbool): PWideChar; stdcall;
Introduced in version 9.5.0.65

Returns the time in Unix format (in seconds since the epoch: 00:00:00 UTC on 1 January 1970).

bLocal indicates whether the date/time returned is local or UTC.

Returns True for success, False for failure.

More Information and Examples
top
GetDosDateHigh
function CkDateTime_GetDosDateHigh(objHandle: HCkDateTime;
    bLocal: wordbool): Word; stdcall;

Returns the high-order 16-bit integer of the date/time in DOS format. (See GetAsDosDate for more information.)

top
GetDosDateLow
function CkDateTime_GetDosDateLow(objHandle: HCkDateTime;
    bLocal: wordbool): Word; stdcall;

Returns the low-order 16-bit integer of the date/time in DOS format. (See GetAsDosDate for more information.)

top
GetDtObj
function CkDateTime_GetDtObj(objHandle: HCkDateTime;
    bLocal: wordbool): HCkDtObj; stdcall;
Introduced in version 9.5.0.47

Gets the date/time as a Chilkat "Dt" object.

Returns nil on failure

More Information and Examples
top
LoadTaskResult
function CkDateTime_LoadTaskResult(objHandle: HCkDateTime;
    task: HCkTask): wordbool; stdcall;
Introduced in version 9.5.0.52

Loads the date/time from a completed asynchronous task.

Returns True for success, False for failure.

top
OlderThan
function CkDateTime_OlderThan(objHandle: HCkDateTime;
    n: Integer;
    units: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.67

Returns True if the date/time is older than the current system date/time by n seconds/minutes/hours/days. Otherwise returns False. The units can be "seconds", "minutes", "hours", or "days" (plural or singular).

top
Serialize
function CkDateTime_Serialize(objHandle: HCkDateTime;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__serialize(objHandle: HCkDateTime): PWideChar; stdcall;

Serializes the date/time to a us-ascii string that can be imported at a later time via the DeSerialize method. The format of the string returned by this method is not intended to match any published standard. It is formatted to a string with SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1 or 0.

Returns True for success, False for failure.

top
SetFromCurrentSystemTime
function CkDateTime_SetFromCurrentSystemTime(objHandle: HCkDateTime): wordbool; stdcall;

Sets the date/time from the current system time.

top
SetFromDateTimeTicks
function CkDateTime_SetFromDateTimeTicks(objHandle: HCkDateTime;
    bLocal: wordbool;
    ticks: Int64): wordbool; stdcall;

Sets the date/time from a .NET DateTime value represented in ticks. See GetAsDateTimeTicks for more information.

bLocal indicates whether the passed in date/time is local or UTC.

top
SetFromDosDate
function CkDateTime_SetFromDosDate(objHandle: HCkDateTime;
    bLocal: wordbool;
    t: LongWord): wordbool; stdcall;

Sets the date/time from a 32-bit DOS date/time bitmask. See GetAsDosDate for more information.

top
SetFromDosDate2
function CkDateTime_SetFromDosDate2(objHandle: HCkDateTime;
    bLocal: wordbool;
    datePart: Word;
    timePart: Word): wordbool; stdcall;

Sets the date/time from two 16-bit integers representing the high and low words of a 32-bit DOS date/time bitmask. See GetAsDosDate for more information.

bLocal indicates whether the passed in date/time is local or UTC.

top
SetFromDtObj
function CkDateTime_SetFromDtObj(objHandle: HCkDateTime;
    dt: HCkDtObj): wordbool; stdcall;
Introduced in version 9.5.0.47

Sets the date/time from a Chilkat "Dt" object.

Returns True for success, False for failure.

top
SetFromFileTime
function CkDateTime_SetFromFileTime(objHandle: HCkDateTime;
    bLocal: wordbool;
    fTime: FILETIME &): wordbool; stdcall;

Sets the date/time from a Windows FILETIME structure.

bLocal indicates whether the passed in date/time is local or UTC.

For non-Windows systems, the FILETIME structure is defined in the FileTime.h header provided in the Chilkat C/C++ libs distribution. The structure is defined as follows:

typedef struct _FILETIME
    {
    unsigned long dwLowDateTime;
    unsigned long dwHighDateTime;
    } 	FILETIME;

top
SetFromNtpServer
function CkDateTime_SetFromNtpServer(objHandle: HCkDateTime;
    jsonStr: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.96

Sets the date/time by sending a query to an NTP server.

Note: The SetFromNtpServer method is available starting in v9.5.0.96 for most Chilkat builds, but not all. If the SetFromNtpServer method is not present, contact support@chilkatsoft.com for a hotfix build. It should be available in all programming languages/platforms starting in v9.5.0.97

Returns True for success, False for failure.

More Information and Examples
top
SetFromNtpTime
function CkDateTime_SetFromNtpTime(objHandle: HCkDateTime;
    ntpSeconds: Integer): wordbool; stdcall;
Introduced in version 9.5.0.50

Sets the date/time from a 32-bit NTP time value. ntpSeconds is the number of seconds since 00:00 (midnight) 1 January 1900 GMT.

top
SetFromOleDate
function CkDateTime_SetFromOleDate(objHandle: HCkDateTime;
    bLocal: wordbool;
    dt: Double): wordbool; stdcall;

Sets the date/time from a Windows OLE "DATE" value.

bLocal indicates whether the passed in date/time is local or UTC.

Note: This method was not working correctly. The problem was discovered just after releasing v9.5.0.65. It will be fixed in the next version update.

top
SetFromRfc822
function CkDateTime_SetFromRfc822(objHandle: HCkDateTime;
    rfc822Str: PWideChar): wordbool; stdcall;

Sets the date/time from an RFC822 date/time formatted string. Here are some examples of RFC822 formatted date/times:

Tue, 15 Nov 2022 22:00:58 +0000
Tue, 15 Nov 2022 20:21:50 +0100
Tue, 01 Nov 2022 18:09:41 -0600

Returns True for success, False for failure.

top
SetFromTimestamp
function CkDateTime_SetFromTimestamp(objHandle: HCkDateTime;
    timestamp: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the date/time from an RFC 3339 timestamp format. (such as "1990-12-31T23:59:60Z:")

(This is an ISO 8061 format like the following: YYYY-MM-DDThh:mm:ssTZD)

Note: Starting in v9.5.0.77, strings formatted as "YYMMDDhhmmssZ", such as "181221132225Z", can also be passed to this method.

Returns True for success, False for failure.

top
SetFromUlid
function CkDateTime_SetFromUlid(objHandle: HCkDateTime;
    bLocal: wordbool;
    ulid: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.94

Sets this object's date/time using the timestamp embedded in the ulid. If the ulid was not a valid ULID, returns False and the date/time is not set. bLocal indicates whether the ulid uses a local time or UTC time.

Returns True for success, False for failure.

More Information and Examples
top
SetFromUnixTime
function CkDateTime_SetFromUnixTime(objHandle: HCkDateTime;
    bLocal: wordbool;
    t: LongWord): wordbool; stdcall;

Sets the date/time from a 32-bit UNIX time value. (See GetAsUnixTime for information about the Y2038 problem.)

bLocal indicates whether the passed in date/time is local or UTC.

top
SetFromUnixTime64
function CkDateTime_SetFromUnixTime64(objHandle: HCkDateTime;
    bLocal: wordbool;
    t: Int64): wordbool; stdcall;

The same as SetFromUnixTime, except that it uses a 64-bit integer to solve the Y2038 problem. (See GetAsUnixTime for more information about Y2038).

bLocal indicates whether the passed in date/time is local or UTC.

top
SetFromUnixTimeDbl
function CkDateTime_SetFromUnixTimeDbl(objHandle: HCkDateTime;
    bLocal: wordbool;
    d: Double): wordbool; stdcall;

The same as SetFromUnixTime, except that it uses a double to solve the Y2038 problem. (See GetAsUnixTime for more information about Y2038).

bLocal indicates whether the passed in date/time is local or UTC.

top
UlidGenerate
function CkDateTime_UlidGenerate(objHandle: HCkDateTime;
    bLocal: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkDateTime__ulidGenerate(objHandle: HCkDateTime;
    bLocal: wordbool): PWideChar; stdcall;
Introduced in version 9.5.0.94

Generates and returns a new ULID using this object's date/time value. bLocal indicates whether to use local time or UTC time.

Returns True for success, False for failure.

More Information and Examples
top
UlidIncrement
function CkDateTime_UlidIncrement(objHandle: HCkDateTime;
    ulid: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.94

Increments the ULID that is passed in ulid.

More Information and Examples
top
UlidValidate
function CkDateTime_UlidValidate(objHandle: HCkDateTime;
    ulid: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.94

Validates the ulid. Returns True if the ulid is valid, otherwise returns False.

Returns True for success, False for failure.

More Information and Examples
top