Skip to main content

%Library.PosixTime

datatype class %Library.PosixTime

ODBC Type: TIMESTAMP

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).

Method Inventory

Parameters

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.
parameter INDEXNULLMARKER = -1E19;
Declares the default null marker value to use in index subscripts for properties of type %PosixTime
parameter JSONTYPE = number;
JSONTYPE is JSON type used for this datatype.
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.
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.
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.
parameter XMLTIMEZONE = 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.
parameter XSDTYPE = dateTime;
Declares the XSD type used when projecting XML Schemas.

Methods

classmethod CurrentTimeStamp(precision As %Library.Integer = 6) as %Library.PosixTime
Returns the current logical %PosixTime value.
classmethod CurrentUTCTimeStamp(precision As %Library.Integer = 6) as %Library.PosixTime
Returns the current logical UTC %PosixTime value.
classmethod DateToLogical(%val As %Date) as %Library.PosixTime
Converts a logical %Date value to logical %PosixTime value.
classmethod DisplayToLogical(%val As %RawString) as %PosixTime
Converts the input value %val, which represents a display timestamp value, in a logical %PosixTime value.
classmethod IsValid(%val As %RawString) as %Status
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.
classmethod JSONToLogical(%val As %BigInt) as %PosixTime
Converts the JSON UNIX time to logical %PosixTime.
classmethod LogicalToDate(%val As %Library.PosixTime) as %Library.Date
Converts a logical %PosixTime value to a logical %Date value.
classmethod LogicalToDisplay(%val As %PosixTime) as %String
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.
classmethod LogicalToJSON(%val As %FilemanTimeStamp) as %BigInt
Converts the logical %PosixTime value to the JSON integer UNIX time value.
classmethod LogicalToOdbc(%val As %PosixTime) as %TimeStamp
Converts %val, which represents a logical %PosixTime value into an ODBC format TIMESTAMP value
classmethod LogicalToTime(%val As %Library.PosixTime) as %Library.Time
Converts a logical %PosixTime value to a logical %Time value.
classmethod LogicalToTimeStamp(%val As %Library.PosixTime) as %Library.TimeStamp
Converts a logical %PosixTime value to a logical %TimeStamp value.
classmethod LogicalToUnixTime(%val As %Library.PosixTime) as %Library.Decimal
Converts a logical %PosixTime value to a Unix time value (number of seconds before or after 01 Jan 1970 00:00:00.000000).
classmethod LogicalToXSD(%val As %PosixTime) as %String
Converts the %PosixTime value to the canonical SOAP encoded value.
classmethod Normalize(%val As %RawString) as %PosixTime
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
classmethod OdbcToLogical(%val As %RawString) as %Library.PosixTime
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.

classmethod TimeStampToLogical(%val As %Library.TimeStamp) as %Library.PosixTime
Converts a logical %TimeStamp value to a logical %PosixTime value.
classmethod TimeToLogical(%val As %Library.Time) as %Library.PosixTime
Converts a logical %Time value to a logical %PosixTime value.
classmethod UnixTimeToLogical(%val As %Library.Decimal) as %Library.PosixTime
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.
classmethod XSDToLogical(%val As %String) as %PosixTime
Converts the SOAP encoded input datetime value into a %PosixTime value.
FeedbackOpens in a new tab