The EGL Date type is a value type that lets you create a date value. In Eclipse IDE for EGL Developers, the type definition for Date is EDate.
eglx.lang
result Date; result02 Date = "01-04-2009";
/** * A date stores a day, month, and year. */ externalType EDate extends AnyValue type ClassType /** * {@Operation <} Compares two dates. */ static function $LT(lvalue EDate in, rvalue EDate in) returns (EBoolean) {@Operation{"<"}}; /** * {@Operation >} Compares two dates. */ static function $GT(lvalue EDate in, rvalue EDate in) returns (EBoolean) {@Operation{">"}}; /** * {@Operation <=} Compares two dates. */ static function $LTE(lvalue EDate in, rvalue EDate in) returns (EBoolean) {@Operation{"<="}}; /** * {@Operation >=} Compares two dates. */ static function $GTE(lvalue EDate in, rvalue EDate in) returns (EBoolean) {@Operation{">="}}; /** * {@Operation ==} Compares two dates. */ static function $EQ(lvalue EDate in, rvalue EDate in) returns(EBoolean) {@Operation{"=="}}; /** * {@Operation !=} Compares two dates. */ static function $NEQ(lvalue EDate in, rvalue EDate in) returns(EBoolean) {@Operation{"!="}}; /** * {@Operation narrow} Converts a string to a date. The string is parsed * by searching for the month, then the day, then the year. One or two digits * can be specified for the month and day. The year requires a minimum of one * digit and a maximum of at least four digits (in other words, some implementations * can support years beyond 9999). One separator character is required between * the month and day, and another between the day and year. The separator * character can be anything, even a digit (though that's probably a bad idea) * and the two separator characters don't have to be identical. * * @throws TypeCastException if the string can't be parsed into a date. */ static function asDate(value EString in) returns (EDate) {@Operation{"narrow"}}; // this replaces date-time math: date - date = int /** * Returns the number of days between two dates. The result is positive when * this date is later than the other date, and negative when the other date * is later than this date. * * @param other the other date. * @return how many days the two days differ. */ function daysDifferent(other EDate in) returns(EInt); // this replaces date-time math: number + date = date, data +/- number = date /** * Returns a new date representing this date plus a given number of days. * Use negative numbers to subtract days instead of adding them. * * @param days the number of days to add. * @return a new date. */ function addDays(days EInt in) returns(EDate); /** * Creates a timestamp from a date. * * @param timeSpanPattern the desired pattern for the timestamp. * @return a new timestamp. */ function extend(timeSpanPattern EString in) returns(ETimestamp); end
Conversion rules | Reference |
---|---|
To convert a string to a date. | See the earlier comments for the asString function. |
To convert a date 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: result03 Date = "01/04/2009"; sysLib.writeStdOut(result03 as String); Here is the
example output:
2009-01-04 12:01 |
To convert a date to a string, in the presence of a format. | See “StringLib.format.” Also, note the set of useful date formats in “Constants library.” |
Target | Issue |
---|---|
Java | No issues. |
JavaScript | No issues. |