Home > Class Reference > %SYS namespace > %Library.PosixTime

%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 the number of seconds since (or before) January 1, 1970 00:00:00, encoded as a 64-bit integer. The encoding takes the Posix Time, multiplies by 1000000, and adds 2^60. To decode a %PosixTime in to Posix Time, take the logical %PosixTime value, subtract 2^60, and divide by 1000000. While this makes the logical value of %PosixTime a bit unwieldy to deal with by itself, it does make the logical value non-ambiguous when also dealing with %Date and %TimeStamp logical values. %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. 6 digits of precision are supported for the %PosixTime value.

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

parameter DATEFORMAT;
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;
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 [ Language = objectscript ]
Returns the current logical %PosixTime value.
classmethod CurrentUTCTimeStamp(precision As %Library.Integer = 6) as %Library.PosixTime [ Language = objectscript ]
Returns the current logical UTC %PosixTime value.
classmethod DateToLogical(%val As %Date) as %Library.PosixTime [ Language = objectscript ]
Converts a logical %Date value to logical %PosixTime value.
classmethod DisplayToLogical(%val As %RawString) as %PosixTime [ Language = objectscript ]
Converts the input value %val, which represents a display timestamp value, in a logical %PosixTime value.
classmethod IsValid(%val As %RawString) as %Status [ Language = objectscript ]
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 [ Language = objectscript ]
Converts the JSON UNIX time to logical %PosixTime.
classmethod LogicalToDate(%val As %Library.PosixTime) as %Library.Date [ Language = objectscript ]
Converts a logical %PosixTime value to a logical %Date value.
classmethod LogicalToDisplay(%val As %PosixTime) as %String [ Language = objectscript ]
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 [ Language = objectscript ]
Converts the logical %PosixTime value to the JSON integer UNIX time value.
classmethod LogicalToOdbc(%val As %PosixTime) as %TimeStamp [ Language = objectscript ]
Converts %val, which represents a logical %PosixTime value into an ODBC format TIMESTAMP value
classmethod LogicalToTime(%val As %Library.PosixTime) as %Library.Time [ Language = objectscript ]
Converts a logical %PosixTime value to a logical %Time value.
classmethod LogicalToTimeStamp(%val As %Library.PosixTime) as %Library.TimeStamp [ Language = objectscript ]
Converts a logical %PosixTime value to a logical %TimeStamp value.
classmethod LogicalToUnixTime(%val As %Library.PosixTime) as %Library.BigInt [ Language = objectscript ]
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 [ Language = objectscript ]
Converts the %PosixTime value to the canonical SOAP encoded value.
classmethod Normalize(%val As %RawString) as %PosixTime [ Language = objectscript ]
Converts %val to a normalized %PosixTime value. 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
classmethod OdbcToLogical(%val As %RawString) as %Library.PosixTime [ Language = objectscript ]
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 [ Language = objectscript ]
Converts a logical %TimeStamp value to a logical %PosixTime value.
classmethod TimeToLogical(%val As %Library.Time) as %Library.PosixTime [ Language = objectscript ]
Converts a logical %Time value to a logical %PosixTime value.
classmethod UnixTimeToLogical(%val As %Library.BigInt) as %Library.PosixTime [ Language = objectscript ]
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 [ Language = objectscript ]
Converts the SOAP encoded input datetime value into a %PosixTime value.