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

yearmonthday function #18

Closed
Balinus opened this issue Nov 13, 2018 · 2 comments
Closed

yearmonthday function #18

Balinus opened this issue Nov 13, 2018 · 2 comments

Comments

@Balinus
Copy link
Contributor

Balinus commented Nov 13, 2018

Hello again!

Similar to the daysinmonth issue, I think another useful function would be the yearmonthday.

To put in context, I'm developing a function that does some daily calculation from sub-daily temporal data (daily means, sums, etc..). Hence, to construct the output array (daily data), I need to know how many unique days is contained in the input array (sub-hourly data).

For example:

using Dates
d = DateTime(2000, 01, 01, 0, 0, 0):Hour(1):DateTime(2000,12, 31)
arraylen = unique(Dates.yearmonthday.(Dates.days.(d)))

dataout = Array{Float64}(undef, N, M, arraylen)

But the function is not defined for DateTimeNoLeap, etc...

For reference, the original Julia Dates yearmonthday function is here.
https://github.com/JuliaLang/julia/blob/c670f1acdba1971b8545f1c3f3b0cfe55ee0d3f5/stdlib/LibGit2/src/signature.jl#L40

Alexander-Barth added a commit that referenced this issue Nov 14, 2018
@Alexander-Barth
Copy link
Owner

Hi Philippe, I just implemented these functions:

julia> Dates.yearmonthday(NCDatasets.DateTimeStandard(2004,1,1,0,0,0))
(2004, 1, 1)

julia> Dates.yearmonth(NCDatasets.DateTimeStandard(2004,1,1,0,0,0))
(2004, 1)

If this is OK, I will make a new release (unless there are some other one-line-functions to implement for the next release)

@Balinus
Copy link
Contributor Author

Balinus commented Nov 15, 2018

Nice, thanks Alexander! Really appreciated!

No other functions comes to mind right now.

@Balinus Balinus closed this as completed Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants