Skip to content

Commit

Permalink
Allow dates to be computed, other improvements from review
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed May 12, 2021
1 parent 3ad8a48 commit 76782c6
Showing 1 changed file with 46 additions and 16 deletions.
62 changes: 46 additions & 16 deletions proposals/date_shift.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"id": "date_shift",
"summary": "Calculates and manipulates dates and times",
"description": "Allows to calculate a new date and time based on a given date and time by adding or subtracting a given temporal period.",
"description": "Based on a given date (and optionally time), calculates a new date (and time if given) by adding or subtracting a given temporal period. If the given date doesn't include a time component, the returned values will also not include the time component.\n\nThis process doesn't change the time zone and also doesn't take daylight saving time (DST) into account.",
"categories": [
"date & time"
],
"experimental": true,
"parameters": [
{
"name": "data",
"description": "The base date and time to manipulate.\n\nThe millisecond part of the date and time is optional and defaults to 0 if not given. The time zone never changes.",
"schema": {
"type": "string",
"format": "date-time",
"subtype": "date-time"
}
"description": "The date (and optionally time) to manipulate.\n\nIf the given date doesn't include the time, the process assumes that the time component is `00:00:00Z` (i.e. midnight, in UTC). The millisecond part of the time is optional and defaults to 0 if not given.",
"schema": [
{
"type": "string",
"format": "date-time",
"subtype": "date-time"
},
{
"type": "string",
"format": "date",
"subtype": "date"
}
]
},
{
"name": "value",
Expand All @@ -25,7 +32,7 @@
},
{
"name": "unit",
"description": "The unit for the value given. The following pre-defined units are available:\n\n- millisecond: Milliseconds\n- second: Seconds\n- minute: Minutes\n- hour: Hours\n- day: Days - changes only the the day part of a date (and potentially also the month and the year)\n- week: Weeks (equivalent to 7 days)\n- month: Months - changes only the month part of a date (and potentially also the year)\n- year: Years - changes only the year part of a date\n",
"description": "The unit for the value given. The following pre-defined units are available:\n\n- millisecond: Milliseconds\n- second: Seconds\n- minute: Minutes\n- hour: Hours\n- day: Days - changes only the the day part of a date (and potentially also the month and the year)\n- week: Weeks (equivalent to 7 days)\n- month: Months - changes only the month part of a date (and potentially also the year)\n- year: Years - changes only the year part of a date\n\nIf any of the changes result in an invalid date, the corresponding part is rounded down to the next valid date. For example, adding a month to `2020-01-31` would result in `2020-02-29`.",
"schema": {
"type": "string",
"enum": [
Expand All @@ -42,21 +49,28 @@
}
],
"returns": {
"description": "The manipulated date and time.",
"schema": {
"type": "string",
"format": "date-time",
"subtype": "date-time"
}
"description": "The manipulated date (and time if a time component is given in the parameter `data`).",
"schema": [
{
"type": "string",
"format": "date-time",
"subtype": "date-time"
},
{
"type": "string",
"format": "date",
"subtype": "date"
}
]
},
"examples": [
{
"arguments": {
"data": "2020-02-01T17:22:45Z",
"data": "2020-02-29T17:22:45Z",
"value": 1,
"unit": "year"
},
"returns": "2021-02-01T17:22:45Z"
"returns": "2021-02-28T17:22:45Z"
},
{
"arguments": {
Expand All @@ -81,6 +95,22 @@
"unit": "millisecond"
},
"returns": "2018-12-31T17:22:46.150Z"
},
{
"arguments": {
"data": "2018-01-01",
"value": 25,
"unit": "hour"
},
"returns": "2018-01-02"
},
{
"arguments": {
"data": "2018-01-01",
"value": -1,
"unit": "hour"
},
"returns": "2017-12-31"
}
]
}

0 comments on commit 76782c6

Please sign in to comment.