Timestamp and ETimestamp types

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.

EGL package name

eglx.lang

Example use
After the following code runs, the value of result is the current timestamp:
result Timestamp("yyyyMMddHHmm");
Here is a way to assign a timestamp instance:
result02 Timestamp? = new Timestamp("yyyyMMddHHmm");
Type detail
In the following detail, the Operation annotation indicates that the specified operation is available. For example, use “==” to compare two values, not “$EQ”. Two exceptions are the widen and narrow operations, which are invoked during data conversions; for example, when the as operator is used.
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
Comments
Timestamp supports values with fractions of a second to 6 digits. However, the precision of the value stored at runtime is platform specific, and fewer digits might be supported.

Table 1. For additional information
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.”
Compatibility
Table 2. Compatibility
Target Issue
Java No issues.
JavaScript No issues.