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

Feature request: allow TimePeriod constructors of the form 25*Millisecond #10449

Closed
jiahao opened this issue Mar 8, 2015 · 8 comments
Closed
Labels
dates Dates, times, and the Dates stdlib module

Comments

@jiahao
Copy link
Member

jiahao commented Mar 8, 2015

Currently one has to construct a TimePeriod using the constructor syntax Dates.Millisecond(25). In contrast, it is much more natural to use Millisecond as a unary postfix unit (like what SIUnits.jl does), and have 25*Dates.Millisecond produce the same result.

@milktrader
Copy link
Contributor

+1

@quinnj
Copy link
Member

quinnj commented Mar 8, 2015

We could define lowercase as a unit millisecond = Millisecond(1) or overload *(x,::Type{Millisecond}) = x*Millisecond(1). Honestly I kind of prefer how it is though; personally I find Millisecond(25) to be more natural.

@milktrader
Copy link
Contributor

We could have both, no?

@jiahao
Copy link
Member Author

jiahao commented Mar 8, 2015

Consider the use cases involving time arithmetic:

Minute(30)/Second(1) vs (30*Minute)/(1*Second)

or

Hour(6) + Minute(28) + Second(3) vs 6Hour + 28Minute + 3Second

The latter expressions feel much more natural as scientific calculations.

@nalimilan
Copy link
Member

+1, but it feels more natural in lowercase.

@jiahao
Copy link
Member Author

jiahao commented Mar 8, 2015

I'm sure the Germans would disagree ;)

I thought lowercase constructors were going away in #1470?

@quinnj
Copy link
Member

quinnj commented Mar 8, 2015

Technically millisecond wouldn't be a constructor, just a "unit".

@quinnj quinnj added the dates Dates, times, and the Dates stdlib module label Aug 18, 2015
@quinnj
Copy link
Member

quinnj commented Oct 4, 2018

I think Millisecond(25) is simple enough; we can re-open if people want to further discuss or voice more support for this now-3.5-year-old issue.

@quinnj quinnj closed this as completed Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dates Dates, times, and the Dates stdlib module
Projects
None yet
Development

No branches or pull requests

4 participants