datetime
Datumsfunktionen für das JDito
Methods
clearTime
clearTime(
pDate,pTimeZone?):number
Returns the passed date at midnight.
Parameters
numberThe input date in UTC.
string | number | booleanThe time zone in which the UTC timestamp at midnight is required. If you omit this parameter, the client timezone will be used. (http:/joda-time.sourceforge.net/timezones.html)
Returns
numberThe date based on the client time.
Example
let date = vars.getString("$sys.date");
let cleartime = datetime.clearTime(date, "Europe/London");
logging.log(datetime.toDate(date, "dd.MM.yyyy HH:mm:ss"));
logging.log(datetime.toDate(cleartime, "dd.MM.yyyy HH:mm:ss"));
date
date():
number
Returns the current time.
Returns
numberThe current timestamp, in milliseconds, in the UTC time zone.
Example
let date = datetime.date();
logging.log("Today's date: " + datetime.toDate(date, "dd.MM.yyyy"));
getTimeZoneIDs
getTimeZoneIDs(
pGeo):Map<any,any>
Returns all Timezone ID's where a geographic assignement is available as map. Example: key = "Europe/Berlin", value = "Europe/Berlin". If one of the GEO_XXX constants is applied, then all Timezones of this region are at the beginning of that map. If null or any other number is applied, then the map is in alphabetical order.
Parameters
numbernull, or one of the GEO_XXX constants.
Returns
Map<any, any>always an ordered map where key and value are the same.
isToday
isToday(
pTimestamp,pTimeZone?):boolean
Checks if the given timestamp is today in the specified timezone
Parameters
numberanyReturns
booleantrue if it is today
isTomorrow
isTomorrow(
pTimestamp,pTimeZone?):boolean
Checks if the given timestamp is tomorrow in the specified timezone
Parameters
numberanyReturns
booleantrue if it is tomorrow
localTimestamp
localTimestamp(
pDate?):string
Returns the current time in the timezone as a timestamp in ISO 8601:2000 format (2016-09-13).
Parameters
numberThe timestamp in UTC as a "long" value, e.g. as returned by $sys.date.
Returns
stringThe date in the time zone of the process in the corresponding format.
Example
let time = datetime.localTimestamp(vars.getString("$sys.date"));
logging.log(time);
resolveRelativeDateExpression
resolveRelativeDateExpression(
pExpression,pRelativeTo?,pTimeZone?):number[]
Will resolve the given expression into a timespan. The returned array contains the start and end time as milliseconds since epoche. The start is on index 0 and the end on index 1. This will calculate the relative timespan against the given relative date time.
If no timezone is set or this is null, "UTC" is used as default
Parameters
string | number | booleanThe expression to resolve.
numberThe date time in milliseconds against which the relative timespan will be calculated.
string | number | booleanthe timezone of the requested date, e.g. "UTC"
Returns
number[]Array with the start and end milliseconds.
Throws
AditoException
Example
let result = datetime.resolveRelativeDateExpression("REL=ADJUSTED;UNIT=YEAR", datetime.date(), "Europe/Berlin");
let start = result[0]; let end = result[1];
switchTimezone
switchTimezone(
pTime,pFromTimeZone,pToTimeZone):number
Converts the date of any time zone to a date of another time zone.
If no timezone is set or this is null, "UTC" is used as default
Parameters
numberthe date in the timezone of pFromTimeZone
string | number | booleanthe timezone of the date, e.g. "UTC"
string | number | booleanthe timezone of the target, e.g. "UTC"
Returns
numberthe converted date
Example
let result = datetime.switchTimezone(datetime.date(), vars.get("$sys.timezone"), "UTC");
timestamp
timestamp(
pDate?):string
Returns the given time in UTC as a timestamp in ISO 8601:2000 format (2016-09-13).
Parameters
numberThe timestamp in UTC as a "long" value, e.g. as returned by $sys.date.
Returns
stringThe date in the corresponding format, in UTC.
Example
let time = datetime.timestamp(vars.getString("$sys.date"));
logging.log(time);
toDate
toDate(
pDateAsLong,pPattern?,pTimeZone?,pLocale?):string
Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string using a format pattern.
See also "Date Formatting Patterns" in the JDito-JavaScript manual.
Parameters
string | number | booleanThe input value as an integer date value in UTC.
string | number | booleanThe pattern to be used for forming the return value.
string | number | booleanThe time zone of the output value (http:/joda-time.sourceforge.net/timezones.html).
string | number | booleanThe locale of the output value
Returns
stringThe formatted output value.
Throws
May throw an exception.
Example
let date = datetime.toDate(vars.getString("$sys.date"), "dd.MM.yyyy", "UTC", "en_US");
logging.log(date);
today
today(
pTimeZone?):number
Returns the current date at midnight.
Parameters
string | number | booleanThe time zone in which the date at midnight is required.
Returns
numberThe date based on the client time (not UTC) at midnight. If the timeZone parameter was specified, the system returns the date at midnight in the specified time zone.
Example
let date = datetime.today("Europe/Berlin");
logging.log("Current time: " + datetime.toDate(date, "dd.MM.yyyy HH:mm:ss"));
toLocaleDate
toLocaleDate(
pDateAsLong,pPattern):string
Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string using a format pattern. In this case, the client's time zone and locale are used.
See also "Date Formatting Patterns" in the JDito-JavaScript manual.
Parameters
string | number | booleanThe input value as an integer date value in UTC.
string | number | booleanThe pattern to be used for forming the return value.
Returns
stringThe formatted output value.
Throws
May throw an exception.
Example
let date = datetime.toLocaleDate(vars.getString("$sys.date"), "dd.MM.yyyy");
logging.log(date);
toLong
toLong(
pDate,pPattern?,pTimeZone?):string
Converts a readable date to a "long" value.
Parameters
string | number | booleanThe input value in any date format. It must be possible to convert this date format using one of the patterns described in the "Date Formatting Patterns" section in the JDito-JavaScript manual.
string | number | booleanThe format of the date you passed.
string | number | booleanThe time zone of the date you passed (http:/joda-time.sourceforge.net/timezones.html).
Returns
stringThe date as a "long" value in UTC.
Throws
May throw an exception.
Properties
Example
let date = datetime.toLong(datetime.toDate(vars.getString("$sys.date")), "dd.MM.yyyy", "Europe/Berlin");
logging.log("Date as Long value: " + date);
DATETIME_PATTERN_ISO_LOCAL_DATE_TIME
stringConstant: Pattern for the datetime format, defined as:
Example
yyyy-MM-dd'T'HH:mm:ss
The pattern will not be translated automatically into the current runtime locale.
DATETIME_PATTERN_ISO_OFFSET_DATE_TIME_MILLIS
stringConstant: Pattern for the datetime format including milliseconds and timezone offset, defined as:
Example
yyyy-MM-dd'T'HH:mm:ss.SSSXXX
The pattern will not be translated automatically into the current runtime locale.
GEO_AFRICA
numberDescribes the geographic area of Africa.
GEO_AMERICA
numberDescribes the geographic area of America.
GEO_ANTARCTICA
numberDescribes the geographic area of Antarctica.
GEO_ARCTIC
numberDescribes the geographic area of Arctic.
GEO_ASIA
numberDescribes the geographic area of Asia.
GEO_ATLANTIC
numberDescribes the geographic area of Atlantic.
GEO_AUSTRALIA
numberDescribes the geographic area of Australia.
GEO_EUROPE
numberDescribes the geographic area of Europe.
GEO_INDIAN
numberDescribes the geographic area of Indian.
GEO_PACIFIC
numberDescribes the geographic area of Pacific.
ONE_DAY
numberOne day in milliseconds
ONE_HOUR
numberOne hour in milliseconds
ONE_MINUTE
numberOne minute in milliseconds
ONE_SECOND
numberOne second in milliseconds
ONE_WEEK
numberOne week in milliseconds