Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date replace and Date get #433

Open
wants to merge 16 commits into
base: draft
Choose a base branch
from
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- New processes in proposal state:
- `date_difference`
- `date_get_component`
- `date_replace`
- `filter_vector`
- `flatten_dimensions`
- `load_geojson`
Expand Down
2 changes: 1 addition & 1 deletion meta/implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ options that can be passed to the corresponsing `methods`:
- `athmospheric_correction`: `options`
- `cloud_detection`: `options`

By default, the parameters don't allow any value except an empty opject.
By default, the parameters don't allow any value except an empty object.
Back-ends have to either remove the parameter or define schema to give user
details about the supported parameters per supported method.

Expand Down
83 changes: 83 additions & 0 deletions proposals/date_get_component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"id": "date_get_component",
"summary": "Gets a part/component of a date",
"description": "Retrieves a specified portion of a given date object.\n It enables the extraction of specific details from a date object, such as year, month, or day.",
PondiB marked this conversation as resolved.
Show resolved Hide resolved
"categories": [
"date & time"
],
"experimental": true,
"parameters": [
{
"name": "date",
"description": "The date (and optionally time) to to get a part of.",
PondiB marked this conversation as resolved.
Show resolved Hide resolved
"schema": [
{
"type": "string",
"format": "date-time",
"subtype": "date-time"
},
{
"type": "string",
"format": "date",
"subtype": "date"
}
]
},
{
"name": "component",
"description": "The component for the value given. The following pre-defined components 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\n- day of week: Day of Week\n- day of year: Day of Year\n- week: Weeks (equivalent to 7 days)\n- week number: Week Number\n- month: Months\n- year: Years\n\nReplacements with the component `year`, `month` or `day` do never change the time.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description needs to be made much more precise with regards to value ranges for example. See comments below.

"schema": {
"type": "string",
"enum": [
"millisecond",
"second",
"minute",
"hour",
"day",
"day of week",
Copy link
Member

@m-mohr m-mohr Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is day of week Monday or Sunday based? Does it start with 0 or 1? Does it return numbers or strings?

"day of year",
"week",
"week number",
Copy link
Member

@m-mohr m-mohr Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero or one based? What's the difference between week and week number?

"month",
"year"
]
}
}
],
"returns": {
"description": "Returns retrieved portion of a date.",
"schema": {
"type": "number"
}
},
"examples": [
{
"arguments": {
"date": "2023-02-01T17:22:45Z",
"component": "month"
},
"returns": 2
},
{
"arguments": {
"date": "2023-03-31T00:00:00+02:00",
"component": "day"
},
"returns": 31
},
{
"arguments": {
"date": "2023-01-01",
"component": "year"
},
"returns": 2023
},
{
"arguments": {
"date": "2023-01-01",
"component": "month"
},
"returns": 1
}
]
}
108 changes: 108 additions & 0 deletions proposals/date_replace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"id": "date_replace",
PondiB marked this conversation as resolved.
Show resolved Hide resolved
"summary": "Replaces a part of a date",
"description": "Replaces a part of a given date string with a new value based on the provided component, allowing for easy replacing of dates.\n\n In case a date/time overflow, the component will be clipped to their respective bounds e.g. if hour is set to 27, it can be clipped to 23. Similarly, if day is set to -40, it can be clipped to the first day of the month",
"categories": [
"date & time"
],
"experimental": true,
"parameters": [
{
"name": "date",
"description": "The date (and optionally time) to replace.\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",
"description": "The period of time in the component given to replace the existing value.",
"schema": {
"type": "integer"
}
},
{
"name": "component",
PondiB marked this conversation as resolved.
Show resolved Hide resolved
"description": "The component for the value given. The following pre-defined components 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\n- month: Months\n- year: Years\n\nReplacements with the component `year`, `month` or `day` do never change the time.",
"schema": {
"type": "string",
"enum": [
"millisecond",
"second",
"minute",
"hour",
"day",
"month",
"year"
]
}
}
],
"returns": {
"description": "The date with replaced value. If a time component was given in the parameter date, the time component is returned with the date. If the date parameter only includes a date component and a time component is replaced, the resulting output will include the time component as well.",
"schema": [
{
"type": "string",
"format": "date-time",
"subtype": "date-time"
},
{
"type": "string",
"format": "date",
"subtype": "date"
}
]
},
"examples": [
{
"arguments": {
"date": "2020-02-01T17:22:45Z",
"value": 6,
"component": "month"
},
"returns": "2020-06-01T17:22:45Z"
},
{
"arguments": {
"date": "2021-03-31T00:00:00+02:00",
"value": 7,
"component": "day"
},
"returns": "2021-03-07T00:00:00+02:00"
},
{
"arguments": {
"date": "2018-01-01",
"value": 2023,
"component": "year"
},
"returns": "2023-01-01"
},
{
"arguments": {
"date": "2018-01-01",
"value": 5,
"component": "month"
},
"returns": "2017-05-01"
},
{
"description": "A date overflow is clipped to the respective bound of the date component.",
"arguments": {
"date": "2023-01-30",
"value": -40,
"component": "day"
},
"returns": "2023-01-01"
}
]
}