Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Use Moment-Timezone for Time (and other related) Spices #2567

Closed
altern8tif opened this issue Mar 11, 2016 · 8 comments
Closed

Use Moment-Timezone for Time (and other related) Spices #2567

altern8tif opened this issue Mar 11, 2016 · 8 comments
Assignees

Comments

@altern8tif
Copy link
Contributor

I was browsing through momentjs-timezone recently and thought that it might actually be possible to replace the Time Spice.

Not to mention, it could also address other IAs such as #2508, #2545, #2156, #1802 or where timezones or daylight savings were not previously considered.

Any thoughts?


IA Page: https://duck.co/ia/view/time

@zachthompson
Copy link
Contributor

@MrChrisW is the maintainer for time.

@moollaza
Copy link
Member

I believe @MrChrisW and I spoke somewhere about this on GitHub, I don't recall if any decisions were made.

It seems like it could potentially replace several Time-related Spice/Goodies. I'm a little concerned with the size of the lib though -- how much would this increase the payload on the page?

@MrChrisW
Copy link
Collaborator

@altern8tif Can we clarify the suggestion of replacing the Time IA with moment timezone.

Do you mean instead of requesting a specific location from the TimeAndData API we only pull the current UTC time and use moment timezone to convert to the relevant zone based on the user query?

@altern8tif
Copy link
Contributor Author

@MrChrisW yup... Seeing as we already have the timezone information in capitals.yml, we should be able to plug it into moment-timezone to output the time based on the user query.

Not sure if there are any benefits from turning it into a Goodie vs a Spice? Or maybe it's a case of "if it ain't broke, don't fix it"?

I think the more immediate benefit would be as per the discussion in #1802...

@marianosimone
Copy link
Collaborator

What's specially interesting about moment's timezone is that it keeps track of DST shifts, which are usually a pain to handle.

Regarding @moollaza's concern about the size, we could consider what amount of the data they offer we really need (maybe in a IA by IA basis), as it seems like they do provide a subset, so we could create our own (for example, some IAs only need the information for the current year... Or even more, just for the current moment!)

@GuiltyDolphin
Copy link
Member

If we do move away from using an API for Time (which I personally think would be best - it is a very simple task we could handle without the dependency) we should move it over to Goodies.

We don't even need to use moment.js for the TZ AFAIK - we can just pass it from the Perl (Perl has great libraries for CLDR support, as well as a library dedicated to Time Zones).

I think the best approach would be Handle Query/Initial time and time zone in Perl -> Pass to JS -> Use moment.js for any additional date requirements -> tick every second and update.

@moollaza
Copy link
Member

@altern8tif we're not only showing results for the locations in Capitals.yml though -- we also use a Deep trigger to get results for other locations like https://duckduckgo.com/?q=time+in+marseille+france&ia=time

AFAIK there's no easy way for us to do that without an API. A pure Perl route would require a DB of all places + logic to figure out the best candidate for a search query -- too much effort required when we have a free API available to us.

@GuiltyDolphin
Copy link
Member

@moollaza True, I keep thinking we have a Perl package for looking up countries! Lets hope the CLDR builds a map of geographical locations!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants