Date

Derived from String, the Internet Object Date is an ISO 8601 compatible date format. It can be represented as YYYY-MM-DD or YYYYMMDD i.e It can be passed with or without separators (- U+002D).

Value

Description

Optional

Default

Example

YYYY

Four-digit decimal number

(0000-9999)

No

-

2020

MM

two-digit decimal number (01-12)

Yes

01

04

DD

two-digit decimal number (01-31)

Yes

01

30

The value for the year must be provided as it does not takes any default value.

It prescribes a minimum four-digit year format from a range 0000 to 9999 to avoid the year 2000 problem. However, years from a range 1583 to 9999 are automatically allowed by a standard, while years prior to 1583 can only be used by mutual agreement of the partners in information interchange.

Date with separators:

Date without Separators:

YYYY-MM-DD = 2020-02-17

YYYYMMDD = 20200217

YYYY-MM = 2020-02

YYYYMM = 202002

YYYY = 2020

YYYY = 2020

Here is the code snippet demonstrates, how to define and use date type.

# Defining date for registeredDate
registeredDate: date
---
~ 2020-09-17    
~ 20200917      # parsed as 2020-09-17
~ 2020-09       # parsed as 2020-09-01
~ 2019          # parsed as 2019-01-01

MemberDef

The Date is derived from the String type, hence it shares the same MemberDef as the String. However, Date enforces additional constraints with respective date format and the same is applicable to the Date MemberDef.

Last updated