The EGL Timestamp type is a value type if declared with a mask and is a non-instantiable reference type if declared without a mask. The type lets you create timestamp values. In Eclipse IDE for EGL Developers, the type definition for Timestamp is ETimestamp.
eglx.lang
result Timestamp("yyyyMMddHHmm");
result02 Timestamp? = new Timestamp("yyyyMMddHHmm");
externalType ETimestamp extends AnyValue type ParameterizableType { parameterizedType = TimestampType } /** * {@Operation <} Compares two timestamps. */ static function $LT(lvalue ETimestamp in, rvalue ETimestamp in) returns (EBoolean) {@Operation{"<"}}; /** * {@Operation >} Compares two timestamps. */ static function $GT(lvalue ETimestamp in, rvalue ETimestamp in) returns (EBoolean) {@Operation{">"}}; /** * {@Operation <=} Compares two timestamps. */ static function $LTE(lvalue ETimestamp in, rvalue ETimestamp in) returns (EBoolean) {@Operation{"<="}}; /** * {@Operation >=} Compares two timestamps. */ static function $GTE(lvalue ETimestamp in, rvalue ETimestamp in) returns (EBoolean) {@Operation{">="}}; /** * {@Operation ==} Compares two timestamps. */ static function $EQ(lvalue ETimestamp in, rvalue ETimestamp in) returns(EBoolean) {@Operation{"=="}}; /** * {@Operation !=} Compares two timestamps. */ static function $NEQ(lvalue ETimestamp in, rvalue ETimestamp in) returns(EBoolean) {@Operation{"!="}}; /** * {@Operation narrow} Converts a string to a timestamp. * The string is parsed by searching for the timestamp fields * specified in the pattern, in order from years down * to fractions of seconds. Each field from the pattern must * be present in the string. Years must be represented with four digits, * fractions of seconds with six digits, and other fields with two digits. * One separator character must appear in between each field. Any character * may be used as a separator, and the separators do not have to match. * * @throws TypeCastException if the string can't be parsed into a timestamp * or the pattern is invalid. */ static function asTimestamp(value EString in, pattern EString in) returns (ETimestamp) {@Operation{"narrow"}}; /** * {@Operation widen} Converts any timestamp to a timestamp * with the specified pattern. */ static function asTimestamp(value ETimestamp in, pattern EString in) returns (ETimestamp) {@Operation{"widen"}}; function dayOf() returns(EInt); function monthOf() returns(EInt); function yearOf() returns(EInt); function weekdayOf() returns(EInt); function dateOf() returns(EDate); //TODO this really should return ETimestamp("hhmmss"). function timeOf() returns(ETimestamp); function extend(timeSpanPattern EString in) returns(ETimestamp); end
Conversion rules | Reference |
---|---|
To convert a string to a timestamp. | See the earlier comments for the asString function. |
To convert a timestamp to a string, in the absence of a format. | See “String and EString types”; in particular,
the comments for the asString function.
As suggested in the following example, the as String clause
invokes that function: result Timestamp("yyyyMMddHHmm") = "200401241201"; sysLib.writeStdOut(result as String); Here is the example
output:
2004-01-24 12:01 |
To convert a timestamp to a string, in the presence of a format. | See “StringLib.format.” Also, note the set of useful formats in “Constants library.” |
Target | Issue |
---|---|
Java | No issues. |
JavaScript | No issues. |