Dateformat

format property in schema facilitates defining any date-time format by using a rich set of tokens using which almost any dateformat can be parsed in DataModel.

A variable of type date-time can be specified in schema as

 { name: 'name_of_variable', 'type': 'dimension', subtype: 'temporal' };

Representation of date and time varies based on geo location and personal preference. DataModel is able to handle all kind of DateFormat possible. By default DataModel recognizes two date format automatically without specifying the format property in schema.

  • Date in miliseconds from epoch date i.e. the result of new Date(2012, 10, 20).getDate()
  • JavaScript Date object.

For any other date format, the format needs to be specified in schema.

 [
     { type: 'dimension', subtype: 'temporal', format: '%Y' }
 ]

Following are the tokens available to specify formats.

Token Description Example
%H 24-hour format of an hour with leading zeros 00 through 23
%l 12-hour format of an hour with leading zeros 01 through 12
%p Uppercase Ante meridiem and Post meridiem am or pm
%p Lowercase Ante meridiem and Post meridiem AM or PM
%M Minutes with leading zeros 00 to 59
%S Seconds, with leading zeros 00 to 59
%a A textual representation of a day, three letters Mon through Sun
%A A full textual representation of the day of the week Sunday through Saturday
%e Day of the month without leading zeros 1 to 31
%d Day of the month, 2 digits with leading zeros 01 to 31
%b A short textual representation of a month, three letters Jan through Dec
%B A full textual representation of a month, such as January or March January to December
%m Numeric representation of a month, with leading zeros 01 through 12
%y A two digit representation of a year 90 for 1990
%Y A full numeric representation of a year, 4 digits 1990

In order to make DataModel recognize 1990-Sep/25 the format specification will be %Y-%b/%e. Here % is a token identifier.