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

Support Linked Timezones #144

Closed
adamsanderson opened this issue Mar 14, 2013 · 5 comments
Closed

Support Linked Timezones #144

adamsanderson opened this issue Mar 14, 2013 · 5 comments
Assignees

Comments

@adamsanderson
Copy link

I may be missing something, but is it possible to reference linked timezones? For instance, I have users with the US/Pacific timezone, which I believe is linked to America/Los_Angeles. If I try to operate on times with US/Pacific, timezone seems to silently assume UTC:

> now
1363302327446
> then = tz(now, 'America/Los_Angeles', '-14 days')
1362096327446
> then = tz(now, 'US/Pacific', '-14 days')
1362092727446

Any suggestions? Also, is there any way to find out if a timezone was not found, a strict mode perhaps?

@bigeasy
Copy link
Owner

bigeasy commented Mar 14, 2013

A bug and a good suggestion. Will fix. Will consider. (Send from phone.)

On Thursday, March 14, 2013, Adam Sanderson wrote:

I may be missing something, but is it possible to reference linked
timezones? For instance, I have users with the US/Pacific timezone, which
I believe is linked to America/Los_Angeles. If I try to operate on times
with US/Pacific, timezone seems to silently assume UTC:

now
1363302327446
then = tz(now, 'America/Los_Angeles', '-14 days')
1362096327446
then = tz(now, 'US/Pacific', '-14 days')
1362092727446

Any suggestions? Also, is there any way to find out if a timezone was not
found, a strict mode perhaps?


Reply to this email directly or view it on GitHubhttps://github.com//issues/144
.

@ghost ghost assigned bigeasy Mar 15, 2013
bigeasy pushed a commit that referenced this issue Mar 15, 2013
Rather than store a link in the JavaScript zone information file, I
instead create a full JavaScript zone information file. When someone is
loading the entire database at once, this is going to be wasteful, but
when someone is requesting timezones over the web as needed, this is
going to be most efficient.

Because I'm using one object to preserve the state of the `tz` function,
I've counted on the fact that the active set of normalized timezone
names all have a slash in them, while all of the zone rules do not.
When adding timezones links, the created a collision when the legacy
timezone name `Cuba` collided with the DST rules named `Cuba`.

The obvious solution to this is to store the names with a `z:` or `r:`
prefix in the enclosed timezone object.

The `US/Pacific` timezone mentioned in #144 is now visible.
@bigeasy
Copy link
Owner

bigeasy commented Mar 15, 2013

Are you blocking on a solution? I can do a release now with this temporary fix. I'll do a more thorough implementation of links over the weekend.

@adamsanderson
Copy link
Author

Thanks for the quick turnaround! Don't worry about a release just for me,
if needed, I can pull your fix from github.

I think I actually need something more low level. I'm doing thousands of
day iterations, thousands of times in a simulation that needs to be DST
aware, ie: it needs accurate wallclock times. I think I might actually
just get a posix day start, then increment by a day of milliseconds, and
adjust whenever I trip over a rule's boundary. I may still use the JSON
datafiles you're producing.

By the way, I really liked your synopsis.js, that's an excellent overview
of the library.

On Fri, Mar 15, 2013 at 1:57 PM, Alan Gutierrez notifications@github.comwrote:

Are you blocking on a solution? I can do a release now with this temporary
fix. I'll do a more thorough implementation of links over the weekend.


Reply to this email directly or view it on GitHubhttps://github.com//issues/144#issuecomment-14984469
.

@bigeasy
Copy link
Owner

bigeasy commented Mar 15, 2013

Thank you for the feedback on synopsis.js. I've not made it prominent because I keep meaning to do something more substantial for documentation, so I can see I'm missing an opportunity because of the something better I'll probably never get around to.

It sounds like you're invoking tz a bunch, so it might actually be performance critical. I've got a handful of branches where I've done optimizations, with some significant improvements. I've held back because I wanted to keep the library tiny (2.7k), but if someone has a need for the performance, it would be worth exploring.

What date string are you using to get local time? I can see if any of the optimizations are faster for that specific case.

@adamsanderson
Copy link
Author

My use case would looks roughly like this:

var pacific = tz('America/Los_Angeles');
var timestamp = 1363302327446; // Some timestamp, I would probably have

some code to pin it to 00:00:00 for the date
var end = 3 * 365; // scan through 3 years

for (var i=0; i < end; i++) {
  process(timestamp)
  timestamp = pacific(timestamp, '+1 day');
}

In process I mucking around with getting hour offsets on timestamp (ie:
timestamp + hours * (60_60_1000) ) and such.

On Fri, Mar 15, 2013 at 4:12 PM, Alan Gutierrez notifications@github.comwrote:

Thank you for the feedback on synopsis.js. I've not made it prominent
because I keep meaning to do something more substantial for documentation,
so I can see I'm missing an opportunity because of the something better
I'll probably never get around to.

It sounds like you're invoking tz a bunch, so it might actually be
performance critical. I've got a handful of branches where I've done
optimizations, with some significant improvements. I've held back because I
wanted to keep the library tiny (2.7k), but if someone has a need for the
performance, it would be worth exploring.

What date string are you using to get local time? I can see if any of the
optimizations are faster for that specific case.


Reply to this email directly or view it on GitHubhttps://github.com//issues/144#issuecomment-14991364
.

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