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/or get processes #254

Open
m-mohr opened this issue May 20, 2021 · 3 comments
Open

Date replace and/or get processes #254

m-mohr opened this issue May 20, 2021 · 3 comments
Assignees
Milestone

Comments

@m-mohr
Copy link
Member

m-mohr commented May 20, 2021

After we've added date_shift, there are some more options that seem obviously useful:

  • date_replace(date, value, unit) -> date - replace parts of a date, e.g. set a date to the first of a month date_replace("2020-05-13", 1, "day") -> "2020-05-01"
  • date_get(date, unit) -> value - get a part of a date, e.g. get the year date_get("2020-05-13", "year") -> 2020 or get the day date_get("2020-05-13", "day") -> 13 (name could also be date_element in accordance to array_element? 😅)

With date_get and date_shift one could emulate date_replace to some degree, but not fully (e.g. can't do the "snap" behavior) so they have both their use cases.

@m-mohr m-mohr added this to the 1.2.0 milestone May 20, 2021
@m-mohr m-mohr changed the title Date processes Date replace and/or get processes May 20, 2021
@m-mohr m-mohr modified the milestones: 1.2.0, 1.3.0 Oct 25, 2021
@m-mohr m-mohr modified the milestones: 1.3.0, 2.0.0, 2.1.0 Feb 1, 2023
@m-mohr m-mohr modified the milestones: 2.1.0, future Mar 8, 2023
@PondiB PondiB self-assigned this Apr 5, 2023
@jdries
Copy link
Contributor

jdries commented Sep 20, 2023

I just had a use case that requires this: for best available pixel compositing, one weighting score is distance to the middle of the compositing period. In the context of a callback, we have access to the time dimension label (date), but we don't necessarily know for which month we are computing a composite.
With date_replace I can do something like:
abs(date_difference(label, date_replace(label, value=15,component="day")))

Seems like we can take the definitions from the PR for an initial implementation!

@PondiB
Copy link
Member

PondiB commented Sep 21, 2023

@jdries sure. @soxofaan are there any further suggestions for PR #433 ?

@soxofaan
Copy link
Member

added some more suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants