Skip to content

Commit 2a2b57f

Browse files
authored
date_difference: Add week as unit #506 (#543)
1 parent 2f97751 commit 2a2b57f

File tree

2 files changed

+101
-99
lines changed

2 files changed

+101
-99
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- `run_ogcapi`
1515
- `run_ogcapi_externally`
1616
- `stac_modify`
17+
- `date_difference`: Allow `week` as a unit [#506](https://github.com/Open-EO/openeo-processes/issues/506)
1718

1819
### Changed
1920

proposals/date_difference.json

Lines changed: 100 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,100 @@
1-
{
2-
"id": "date_difference",
3-
"summary": "Computes the difference between two time instants",
4-
"description": "Computes the difference between two instants in time and returns the difference between them in the unit given.\n\nThe process converts the given dates into numerical timestamps and returns the result of subtracting the other date from the base date. If a 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 times are optional and default to `0` if not given. The process doesn't take daylight saving time (DST) into account as only dates and times in UTC (with potential numerical time zone modifier) are supported.",
5-
"categories": [
6-
"comparison",
7-
"date & time"
8-
],
9-
"experimental": true,
10-
"parameters": [
11-
{
12-
"name": "date1",
13-
"description": "The base date, optionally with a time component.",
14-
"schema": [
15-
{
16-
"type": "string",
17-
"format": "date-time",
18-
"subtype": "date-time"
19-
},
20-
{
21-
"type": "string",
22-
"format": "date",
23-
"subtype": "date"
24-
}
25-
]
26-
},
27-
{
28-
"name": "date2",
29-
"description": "The other date, optionally with a time component.",
30-
"schema": [
31-
{
32-
"type": "string",
33-
"format": "date-time",
34-
"subtype": "date-time"
35-
},
36-
{
37-
"type": "string",
38-
"format": "date",
39-
"subtype": "date"
40-
}
41-
]
42-
},
43-
{
44-
"name": "unit",
45-
"description": "The unit for the returned value. The following units are available:\n\n- millisecond\n- second - leap seconds are ignored in computations.\n- minute\n- hour\n- day\n- month\n- year",
46-
"optional": true,
47-
"default": "second",
48-
"schema": {
49-
"type": "string",
50-
"enum": [
51-
"millisecond",
52-
"second",
53-
"minute",
54-
"hour",
55-
"day",
56-
"month",
57-
"year"
58-
]
59-
}
60-
}
61-
],
62-
"returns": {
63-
"description": "Returns the difference between date1 and date2 in the given unit (seconds by default), including a fractional part if required.\n\nFor comparison purposes this means:\n\n- If `date1` < `date2`, the returned value is positive.\n- If `date1` = `date2`, the returned value is 0.\n- If `date1` > `date2`, the returned value is negative.",
64-
"schema": {
65-
"type": "number"
66-
}
67-
},
68-
"examples": [
69-
{
70-
"arguments": {
71-
"date1": "2020-01-01T00:00:00.0Z",
72-
"date2": "2020-01-01T00:00:15.5Z"
73-
},
74-
"returns": 15.5
75-
},
76-
{
77-
"arguments": {
78-
"date1": "2020-01-01T00:00:00Z",
79-
"date2": "2020-01-01T01:00:00+01:00"
80-
},
81-
"returns": 0
82-
},
83-
{
84-
"arguments": {
85-
"date1": "2020-01-02",
86-
"date2": "2020-01-01"
87-
},
88-
"returns": -86400
89-
},
90-
{
91-
"arguments": {
92-
"date1": "2020-01-02",
93-
"date2": "2020-01-01",
94-
"unit": "day"
95-
},
96-
"returns": -1
97-
}
98-
]
99-
}
1+
{
2+
"id": "date_difference",
3+
"summary": "Computes the difference between two time instants",
4+
"description": "Computes the difference between two instants in time and returns the difference between them in the unit given.\n\nThe process converts the given dates into numerical timestamps and returns the result of subtracting the other date from the base date. If a 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 times are optional and default to `0` if not given. The process doesn't take daylight saving time (DST) into account as only dates and times in UTC (with potential numerical time zone modifier) are supported.",
5+
"categories": [
6+
"comparison",
7+
"date & time"
8+
],
9+
"experimental": true,
10+
"parameters": [
11+
{
12+
"name": "date1",
13+
"description": "The base date, optionally with a time component.",
14+
"schema": [
15+
{
16+
"type": "string",
17+
"format": "date-time",
18+
"subtype": "date-time"
19+
},
20+
{
21+
"type": "string",
22+
"format": "date",
23+
"subtype": "date"
24+
}
25+
]
26+
},
27+
{
28+
"name": "date2",
29+
"description": "The other date, optionally with a time component.",
30+
"schema": [
31+
{
32+
"type": "string",
33+
"format": "date-time",
34+
"subtype": "date-time"
35+
},
36+
{
37+
"type": "string",
38+
"format": "date",
39+
"subtype": "date"
40+
}
41+
]
42+
},
43+
{
44+
"name": "unit",
45+
"description": "The unit for the returned value. The following units are available:\n\n- millisecond\n- second - leap seconds are ignored in computations.\n- minute\n- hour\n- day\n- week\n- month\n- year",
46+
"optional": true,
47+
"default": "second",
48+
"schema": {
49+
"type": "string",
50+
"enum": [
51+
"millisecond",
52+
"second",
53+
"minute",
54+
"hour",
55+
"day",
56+
"week",
57+
"month",
58+
"year"
59+
]
60+
}
61+
}
62+
],
63+
"returns": {
64+
"description": "Returns the difference between date1 and date2 in the given unit (seconds by default), including a fractional part if required.\n\nFor comparison purposes this means:\n\n- If `date1` < `date2`, the returned value is positive.\n- If `date1` = `date2`, the returned value is 0.\n- If `date1` > `date2`, the returned value is negative.",
65+
"schema": {
66+
"type": "number"
67+
}
68+
},
69+
"examples": [
70+
{
71+
"arguments": {
72+
"date1": "2020-01-01T00:00:00.0Z",
73+
"date2": "2020-01-01T00:00:15.5Z"
74+
},
75+
"returns": 15.5
76+
},
77+
{
78+
"arguments": {
79+
"date1": "2020-01-01T00:00:00Z",
80+
"date2": "2020-01-01T01:00:00+01:00"
81+
},
82+
"returns": 0
83+
},
84+
{
85+
"arguments": {
86+
"date1": "2020-01-02",
87+
"date2": "2020-01-01"
88+
},
89+
"returns": -86400
90+
},
91+
{
92+
"arguments": {
93+
"date1": "2020-01-02",
94+
"date2": "2020-01-01",
95+
"unit": "day"
96+
},
97+
"returns": -1
98+
}
99+
]
100+
}

0 commit comments

Comments
 (0)