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

Inconsistent resulting types for zero and one for Dates #36099

Closed
jagot opened this issue Jun 1, 2020 · 3 comments
Closed

Inconsistent resulting types for zero and one for Dates #36099

jagot opened this issue Jun 1, 2020 · 3 comments

Comments

@jagot
Copy link
Contributor

jagot commented Jun 1, 2020

julia> using Dates

julia> x = Date(2020):Week(1):Date(2021)
2020-01-01:1 week:2020-12-30

julia> dx = step(x)
1 week

julia> zero(dx)
0 weeks

julia> one(dx)
1

CC @mcabbott

@mcabbott
Copy link
Contributor

mcabbott commented Jun 1, 2020

I presume the reasoning is this:

julia> one(dx) * Week(3)
3 weeks

julia> zero(dx) + Week(3)
3 weeks

@andreasnoack
Copy link
Member

It's on purpose the one doesn't have units. That's why there is oneunit

julia> oneunit(dx)
1 week

@jagot
Copy link
Contributor Author

jagot commented Jun 1, 2020

That makes sense.

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

3 participants