Skip to main content

%Library.PosixTime

Class %Library.PosixTime [ ClassType = datatype, ClientDataType = TIMESTAMP, OdbcType = TIMESTAMP, SqlCategory = POSIXTS, System = 2 ]

The %PosixTime data type class represents a time stamp value.

The logical value of the %PosixTime data type is based on the number of seconds since (or before) January 1, 1970 00:00:00. The logical values will never collide with those of %Date in a valid range, and will sort chronologically when stored in globals. %PosixTime takes up less disk space and memory than %TimeStamp datatype, and is better for performance than %TimeStamp.

The earliest date supported by %PosixTime is 0001-01-01 00:00:00, which has a logical value of -6979664624441081856. The last date supported is 9999-12-31 23:59:59.999999, which has a logical value of 1406323805406846975. Dates prior to 1970-01-01 00:00:00 have a negative logical value. %PosixTime values have a 1 microsecond resolution. To convert between %PosixTime and %TimeStamp format, call LogicalToTimeStamp(posixtime_value)

To convert between %TimeStamp and %PosixTime format, call TimeStampToLogical(timestamp_value)

To convert between %PosixTime and %Date format, call LogicalToDate(posixtime_value).

To convert between %Date and %PosixTime format, call DateToLogical(date_value). A time of 00:00:00 is used.

To convert between %PosixTime and %Time format, call LogicalToTime(posixtime_value).

To convert between %Time and %PosixTime format, call TimeToLogical(time_value). The current date is used.

To determine if a value is a valid logical %PosixTime value, call IsValid(posixtime_value).

To get the current, local datetime %PosixTime logical value, call CurrentTimeStamp(precision).

To get the current, UTC datetime %PosixTime logical value, call CurrentUTCTimeStamp(precision).

To get a Unix Timestamp value from a %PosixTime logical (local time) value, call LogicalToUnixTime(posixtime_value).

To get a %PosixTime logical value from a Unix Timestamp value, call UnixTimeToLogical(unix_timestamp_value).

Parameters

MAXVAL

Parameter MAXVAL = 1406323805406846975;

The maximum allowed logical value for the data type. By default, a Logical value of 1406323805406846975, which is 9999-12-31 23:59:59.999999.

MINVAL

Parameter MINVAL = -6979664624441081856;

The minimum allowed logical value for the data type. By default, a logical value of -6979664624441081856, which is 0001-01-01 00:00:00.

DATEFORMAT

Parameter DATEFORMAT = 3;

The format specification for the data type's date component display value. The value of the DATEFORMAT parameter corresponds to the available parameters of the $ZDATETIME and $ZDATETIMEH function's fformat value, which is used to perform the formatting of the time component of the timestamp value.

TIMEFORMAT

Parameter TIMEFORMAT = 1;

The format specification for the data type's time component display value. The value of the TIMEFORMAT parameter corresponds to the available parameters of the $ZDATETIME and $ZDATETIMEH function's tformat value, which is used to perform the formatting of the time component of the timestamp value.

XMLTIMEZONE

Parameter XMLTIMEZONE [ Constraint = "IGNORE,UTC", Flags = ENUM ] = "UTC";

XMLTIMEZONE specifies the handling of timezone part of the XML format dateTime. "UTC" means convert to UTC on input. "IGNORE means ignore the timezone.

XMLDEFAULTVALUE

Parameter XMLDEFAULTVALUE As STRING [ Internal ];

XMLDEFAULTVALUE specifies the value to use if the date fails validity check by $zdatetimeh. By default "" is used which will result in an XMLImport error. A dateTime such as "1841-01-1 00:00:00" may be specified to replace dates such as 0001-01-01 00:00:00 which are not valid %TimeStamp dates. For ease of use, specify a %TimeStamp style logical value for XMLDEFAULTVALUE, not a %PosixTime logical value (which is a 64-bit integer).

XSDTYPE

Parameter XSDTYPE = "dateTime";

Declares the XSD type used when projecting XML Schemas.

INDEXNULLMARKER

Parameter INDEXNULLMARKER = "-1E19";

Declares the default null marker value to use in index subscripts for properties of type %PosixTime

JSONTYPE

Parameter JSONTYPE = "number";

JSONTYPE is JSON type used for this datatype.

Methods

XSDToLogical

ClassMethod XSDToLogical(%val As %String) As %PosixTime [ CodeMode = generator, ServerOnly = 1 ]

Converts the SOAP encoded input datetime value into a %PosixTime value.

LogicalToXSD

ClassMethod LogicalToXSD(%val As %PosixTime) As %String [ CodeMode = generator, ServerOnly = 1 ]

Converts the %PosixTime value to the canonical SOAP encoded value.

JSONToLogical

ClassMethod JSONToLogical(%val As %BigInt) As %PosixTime [ CodeMode = generator ]

Converts the JSON UNIX time to logical %PosixTime.

LogicalToJSON

ClassMethod LogicalToJSON(%val As %FilemanTimeStamp) As %BigInt [ CodeMode = generator ]

Converts the logical %PosixTime value to the JSON integer UNIX time value.

OdbcToLogical

ClassMethod OdbcToLogical(%val As %RawString) As %Library.PosixTime [ CodeMode = generator, ServerOnly = 1 ]

Converts %val, which represents either a Timestamp in ODBC format, or a Date in ODBC format, into a logical %PosixTime value.

Returns the logical %PosixTime value of the ODBC Timestamp string %val.

LogicalToOdbc

ClassMethod LogicalToOdbc(%val As %PosixTime) As %TimeStamp [ CodeMode = generator, ServerOnly = 1 ]

Converts %val, which represents a logical %PosixTime value into an ODBC format TIMESTAMP value

DisplayToLogical

ClassMethod DisplayToLogical(%val As %RawString) As %PosixTime [ CodeMode = generator, ServerOnly = 0 ]

Converts the input value %val, which represents a display timestamp value, in a logical %PosixTime value.

LogicalToDisplay

ClassMethod LogicalToDisplay(%val As %PosixTime) As %String [ CodeMode = generator, ServerOnly = 0 ]

Converts the value of %val, which is in logical format as the encoded number of seconds since Jan 01, 1970 00:00:00, into a display timestamp string.

IsValid

ClassMethod IsValid(%val As %RawString) As %Status [ CodeMode = generator, ServerOnly = 0 ]

Tests if the logical value %val, which represents a %PosixTime value, is valid. Input value of a valid %TimeStamp logical value or %Date ODBC value is also allowed. If %TimeStamp logical value or %Date ODBC value is given, it will first be converted to a %PosixTime value The validation is based on the class parameter settings used for the class attribute this data type is associated with. In this case, MAXVAL and MINVAL.

Normalize

ClassMethod Normalize(%val As %RawString) As %PosixTime [ CodeMode = generator, ServerOnly = 1 ]

Converts %val to a normalized %PosixTime value. Input value of a valid %TimeStamp logical value, %Date ODBC value, or %Date logical value is also allowed. If %TimeStamp logical value , %Date ODBC value, or %Date logical value is given, it will first be converted to a %PosixTime value

DateToLogical

ClassMethod DateToLogical(%val As %Date) As %Library.PosixTime [ CodeMode = expression, ServerOnly = 1 ]

Converts a logical %Date value to logical %PosixTime value.

LogicalToDate

ClassMethod LogicalToDate(%val As %Library.PosixTime) As %Library.Date [ CodeMode = generator, ServerOnly = 1 ]

Converts a logical %PosixTime value to a logical %Date value.

LogicalToTime

ClassMethod LogicalToTime(%val As %Library.PosixTime) As %Library.Time [ CodeMode = generator, ServerOnly = 1 ]

Converts a logical %PosixTime value to a logical %Time value.

TimeToLogical

ClassMethod TimeToLogical(%val As %Library.Time) As %Library.PosixTime [ CodeMode = expression, ServerOnly = 1 ]

Converts a logical %Time value to a logical %PosixTime value.

TimeStampToLogical

ClassMethod TimeStampToLogical(%val As %Library.TimeStamp) As %Library.PosixTime [ CodeMode = generator, ServerOnly = 1 ]

Converts a logical %TimeStamp value to a logical %PosixTime value.

LogicalToTimeStamp

ClassMethod LogicalToTimeStamp(%val As %Library.PosixTime) As %Library.TimeStamp [ CodeMode = generator, ServerOnly = 1 ]

Converts a logical %PosixTime value to a logical %TimeStamp value.

LogicalToUnixTime

ClassMethod LogicalToUnixTime(%val As %Library.PosixTime) As %Library.Decimal [ CodeMode = generator, ServerOnly = 1 ]

Converts a logical %PosixTime value to a Unix time value (number of seconds before or after 01 Jan 1970 00:00:00.000000).

UnixTimeToLogical

ClassMethod UnixTimeToLogical(%val As %Library.Decimal) As %Library.PosixTime [ CodeMode = generator, ServerOnly = 1 ]

Converts a a Unix time value (number of seconds before or after 01 Jan 1970 00:00:00.000000 UTC) to a logical local %PosixTime value.

CurrentTimeStamp

ClassMethod CurrentTimeStamp(precision As %Library.Integer = 6) As %Library.PosixTime [ ServerOnly = 1 ]

Returns the current logical %PosixTime value.

CurrentUTCTimeStamp

ClassMethod CurrentUTCTimeStamp(precision As %Library.Integer = 6) As %Library.PosixTime [ ServerOnly = 1 ]

Returns the current logical UTC %PosixTime value.