- Declares a variable of type datetime.
- Type checks an existing variable to determine if it is a valid datetime
Example 1:
include std/datetime.e
datetime x = now() -- x is a datetime variable, and now() returns a datetime
? x
? datetime(x) -- is it a datetime variable?
Results:
{2019,9,8,3,23,23}
1
Example 2:
include std/datetime.e
object y = {2019,01,10} -- y is not a datetime variable, just a sequence containing a date
? y
? datetime(y) -- is this a datetime variable?
Results:
{2019,1,1}
0
Example 3:
include std/datetime.e
datetime z = {2019,01,01} -- z is declared as a datetime type, so it is validated on assignment
-- what we assigned was not a valid datetime, so we get:
-- type_check failure, z is {2019,1,1}