Date - MrKaszeba19/PapajLang GitHub Wiki
Date is a package of functions for PapajScript. This package contains functions that manipulate entities of DateTime type. It was released on March 9, 2021.
The earliest known stable RPN Calculator version to work with String – 0.5.1.
List of Array functions
Notes:
- If you do not want to type
Date.
every time, just type@use(Date)
before. However, if you want to stop using the package, type@unuse(Date)
. - The version 0.5.1.1 is the last version where you can use
Date.
functions without running@use(Date)
. Starting from April 16, 2021, allDate
functions require to be activated by@use(Date)
Currently supported functions
Package Function | Syntax | Output type | Purpose | Since |
---|---|---|---|---|
Date.toDateTime | ENT1 function | DateTime | convert a string or number containing Unix epoch time to DateTime | 0.5.1 |
Date.YMDtoDateTime | STR1 function | DateTime | convert S1 string of yyyy-mm-dd format to DateTime |
0.5.3 |
Date.MDYtoDateTime | STR1 function | DateTime | convert S1 string of mm/dd/yyyy format to DateTime |
0.5.3 |
Date.DMYtoDateTime | STR1 function | DateTime | convert S1 string of dd.mm.yyyy format to DateTime |
0.5.3 |
Date.toTimestamp | DAT1 function | Number | convert a DateTime to Unix epoch time | 0.5.1 |
Date.now | (no args) function | DateTime | get a datetime of current moment | 0.5.1 |
Date.today | (no args) function | DateTime | get a date of current day | 0.5.1 |
Date.yesterday | (no args) function | DateTime | get a date of yesterday | 0.5.1 |
Date.tomorrow | (no args) function | DateTime | get a date of tomorrow | 0.5.1 |
Date.truncDate | DAT1 function | DateTime | Cut a datetime to day part | 0.5.1 |
Date.truncTime | DAT1 function | DateTime | Cut a datetime to time part | 0.5.1 |
Date.getYear | DAT1 function | Number | Get a year part of datetime as a number | 0.5.1 |
Date.getMonth | DAT1 function | Number | Get a month part of datetime as a number | 0.5.1 |
Date.getDay | DAT1 function | Number | Get a day part of datetime as a number | 0.5.1 |
Date.getHour | DAT1 function | Number | Get a hour part of datetime as a number (24-hour clock) | 0.5.1 |
Date.getHour24 | DAT1 function | Number | Get a hour part of datetime as a number (24-hour clock) | 0.5.1 |
Date.getHour12 | DAT1 function | Number | Get a hour part of datetime as a number (12-hour clock) | 0.5.1 |
Date.getMinute | DAT1 function | Number | Get a minute part of datetime as a number | 0.5.1 |
Date.getSecond | DAT1 function | Number | Get a second part of datetime as a number | 0.5.1 |
Date.getMillisecond | DAT1 function | Number | Get a millisecond part of datetime as a number | 0.5.1 |
Date.getWeekDay | DAT1 function | Number | Get a day of the week part of datetime as a number | 0.5.1 |
Date.getYearDay | DAT1 function | Number | Get a day of the year part of datetime as a number | 0.5.1 |
Date.getMonthWeek | DAT1 function | Number | Get a week of the month part of datetime as a number | 0.5.1 |
Date.getYearWeek | DAT1 function | Number | Get a week of the year part of datetime as a number | 0.5.1 |
Date.setYear | DAT1 NUM1 function | DateTime | Set a year part of a datetime D1 using number N1 | 0.5.1 |
Date.setMonth | DAT1 NUM1 function | DateTime | Set a month part of a datetime D1 using number N1 | 0.5.1 |
Date.setDay | DAT1 NUM1 function | DateTime | Set a day part of a datetime D1 using number N1 | 0.5.1 |
Date.setHour | DAT1 NUM1 function | DateTime | Set a hour part of a datetime D1 using number N1 | 0.5.1 |
Date.setMinute | DAT1 NUM1 function | DateTime | Set a minute part of a datetime D1 using number N1 | 0.5.1 |
Date.setSecond | DAT1 NUM1 function | DateTime | Set a second part of a datetime D1 using number N1 | 0.5.1 |
Date.setMillisecond | DAT1 NUM1 function | DateTime | Set a millisecond part of a datetime D1 using number N1 | 0.5.1 |
Date.addYear | DAT1 NUM1 function | DateTime | Add N1 to the year part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addMonth | DAT1 NUM1 function | DateTime | Add N1 to the year part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addWeek | DAT1 NUM1 function | DateTime | Add N1 weeks of datetime D1 (N1 may be negative) | 0.5.2 |
Date.addDay | DAT1 NUM1 function | DateTime | Add N1 to the year part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addHour | DAT1 NUM1 function | DateTime | Add N1 to the year part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addMinute | DAT1 NUM1 function | DateTime | Add N1 to the year part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addSecond | DAT1 NUM1 function | DateTime | Add N1 to the second part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.addMillisecond | DAT1 NUM1 function | DateTime | Add N1 to the millisecond part of datetime D1 (N1 may be negative) | 0.5.1 |
Date.isPM | DAT1 function | Boolean | Determine whether time part of D1 is PM (true ) or AM (false ) |
0.5.1 |
Date.isLeapYear | NUM1 function | Boolean | Determine whether N1 value is a leap year value | 0.5.1 |
Date.isInLeapYear | DAT1 function | Boolean | Determine if D1 is in a leap year | 0.5.1 |
Date.isInRange | DAT1 DAT2 DAT3 function | Boolean | Determine whether D1 is between D2 and D3 | 0.5.2 |
Date.isDateInRange | DAT1 DAT2 DAT3 function | Boolean | Determine whether the date part of D1 is between the date parts of D2 and D3 | 0.5.2 |
Date.isTimeInRange | DAT1 DAT2 DAT3 function | Boolean | Determine whether the time part of D1 is between the time parts of D2 and D3 | 0.5.2 |
Date.unixEpoch | (no args) function | DateTime | get a datetime of Unix epoch zero hour – i.e. January 1, 1970, 12:00am | 0.5.1 |
Date.diffYear | DAT1 DAT2 function | Number | Calculate a number of full years between two datetimes | 0.5.1 |
Date.diffMonth | DAT1 DAT2 function | Number | Calculate a number of full weeks between two datetimes | 0.5.1 |
Date.diffWeek | DAT1 DAT2 function | Number | Calculate a number of full months between two datetimes | 0.5.1 |
Date.diffDay | DAT1 DAT2 function | Number | Calculate a number of full days between two datetimes | 0.5.1 |
Date.diffHour | DAT1 DAT2 function | Number | Calculate a number of full hours between two datetimes | 0.5.1 |
Date.diffMinute | DAT1 DAT2 function | Number | Calculate a number of full minutes between two datetimes | 0.5.1 |
Date.diffSecond | DAT1 DAT2 function | Number | Calculate a number of full seconds between two datetimes | 0.5.1 |
Date.diffMillisecond | DAT1 DAT2 function | Number | Calculate a number of full milliseconds between two datetimes | 0.5.1 |
Date.spanYear | DAT1 DAT2 function | Number | Calculate an approximate number of years between two datetimes | 0.5.1 |
Date.spanMonth | DAT1 DAT2 function | Number | Calculate an approximate number of months between two datetimes | 0.5.1 |
Date.spanWeek | DAT1 DAT2 function | Number | Calculate an approximate number of weeks between two datetimes | 0.5.1 |
Date.spanDay | DAT1 DAT2 function | Number | Calculate an approximate number of days between two datetimes | 0.5.1 |
Date.spanHour | DAT1 DAT2 function | Number | Calculate an approximate number of hours between two datetimes | 0.5.1 |
Date.spanMinute | DAT1 DAT2 function | Number | Calculate an approximate number of minutes between two datetimes | 0.5.1 |
Date.spanSecond | DAT1 DAT2 function | Number | Calculate an approximate number of seconds between two datetimes | 0.5.1 |
Date.spanMillisecond | DAT1 DAT2 function | Number | Calculate an approximate number of milliseconds between two datetimes | 0.5.1 |
Date.format | DAT1 STR1 function | String | Return a string made of a datetime D1 formatted using S1 pattern. See available patterns here | 0.5.1 |
Date.compare | DAT1 STR1 function | Number | Compare two datetimes. If D1 < D2, then return a negative number. If D1 > D2, then return a postitive number. If D1 = D2, then return 0. | 0.5.1 |
Date.compareDate | DAT1 STR1 function | Number | Compare date parts of two datetimes. If D1 < D2, then return a negative number. If D1 > D2, then return a postitive number. If D1 = D2, then return 0. | 0.5.1 |
Date.compareTime | DAT1 STR1 function | Number | Compare time parts of two datetimes. If D1 < D2, then return a negative number. If D1 > D2, then return a postitive number. If D1 = D2, then return 0. | 0.5.1 |
Examples
"2005-04-02 21:37:00" Date.toDateTime -> example
2147483647 Date.toDateTime
Date.now
,Date.tomorrow
,Date.today
,Date.yesterday
2003 Date.isLeapYear
(returnsfalse
)$example Date.isInLeapYear
(returnsfalse
)Date.today -7 Date.addDay
returns a day week ago- Let's use the following as the example:
"1996-06-30" toDateTime -> s "2017-11-13" toDateTime -> t
$t $s diffYear
returns21
as 21 full years are between two dates$t $s spanYear
returns21.3716632443531829
as approximately 21.3716632443531829 years are between two dates$s "mm-dd-yyyy" format
returns"06-30-1996"
$s "mm/dd/yyyy" format
returns"06-30-1996"
$s "mm\"/\"dd\"/\"yyyy" format
returns"06/30/1996"
. See available patterns here