-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time I look at this name all I can see is
WUT
:)5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be some kind of method of now? Or at least call it utcnow.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought about a few different things
Alternatively, I guess we could define some of the TimeZone abstracts here and do
This last one is actually appealing now that I think about it since I was going to provide those definitions in TimeZones.jl anyway.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the only awkward part of the last suggestion is that
now
is exported to top level, whereas I wasn't thinkingUTC
would, So calling it would benow(Dates.UTC)
. Maybe it's not that big a deal though.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
now(Dates.UTC)
will work, butnow(Dates.EST)
will require the TimeZones package?5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the
now(Dates.UTC)
interface but it is weird thatnow(Dates.EST)
wouldn't work without hacking timezones into theDates
module after the fact. MaybeUTC
could be exported? Or maybe it's ok for the TimeZones package to jack definitions back into Dates.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be
now(TimeZones.EST)
and TimeZones wouldn't have to jack anything into the Dates module. There could even be a duplicateTimeZones.UTC
.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be the best option. And if you do
using TimeZones
then you get all of the time zones without prefixes.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather keep
nowutc
, or rename it toutcnow
. Bothnow()
andutcnow()
are kind of timezone agnostic (depends on system settings), and it seems strange to have only one timezone available inDates
.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTC I'd prefer having a single
now
function, it's more consistent and it makes it easier to find the relevant documentation. I don't see it as a problem that if you didn't load theTimeZones
packages, you can only select one time zone: after all, that's what the package is for, and you didn't load it!5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also like
now()
andnow(tz::TimeZone)
methods. I'm OK withDates
only supporting 1 time zone (UTC) andTimeZones
for the rest. The fact that getting UTC time uses a different mechanism under the hood seems like an implementation detail.5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about having offsets from UTC instead of time zones? I.e. You can use any offset from UTC as a pseudo time zone, and now defaults to wherever you currently are. Then now(0) would give you UTC time without needing a time zone object.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution!
, but is it obvious enough that
now(0)
andnow()
gives different answers if your current local time is different from UTC?5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StefanKarpinski That wouldn't be enough, since time zones can change their offsets depending on the period of the year, e.g. with DST. And I can never remember what's my offset from UTC, while I sure know my time zone. :-)
Though both APIs could be supported, of course.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the point – you can use real time zones if you load the TimeZones package but you can get UTC without knowing about time zones. I guess you would just have to document that this is how you get a UTC time without having to load the TimeZones package.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a great idea to have
Base.Dates
include one timezone (UTC), and use timezones in APIs where appropriate. That way there is one general interface, and the TimeZones package provides the extra timezones without changing how things work.And one last plaintive plea for timezones to be instances, and not types. Dumping in an extra 419 types is driving the compiler crazy. It appears to be common to look these up in Dicts. Anything can be a Dict key; they do not have to be types. I realize one reason for this is that as instances they couldn't be used as type parameters, but I'm willing to allow that.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Jeff is spot on – define UTC in Base. It's not like that's going to be a popular name for variables. And yes, can time zones pretty, pretty please be values not types? We can allow arbitrary immutable values as type parameters and then there's no reason for them to be types.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't time zones the epitome of an enum? Whatever the enum type in Julia becomes, it seems time zones should use it.
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I agree with that. But enum values will definitely be instances and not subtypes :)
5999f53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.