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 for date-specific times #54

Open
safinea opened this issue Jul 18, 2014 · 1 comment
Open

Support for date-specific times #54

safinea opened this issue Jul 18, 2014 · 1 comment

Comments

@safinea
Copy link

safinea commented Jul 18, 2014

I would love for this library to support tokens that calculate the time. To be concrete, it would be brilliant if I could, for example, get the sunrise time for a particular date, or the sunset time (e.g. 'next week monday at sunrise'). This depends on a) the date and b) the location. (See also https://github.com/mourner/suncalc) Another example could be 'wakeuptime' that's set to 7:00 during the week and 10:00 in the weekends.

I can imagine something along the lines of registering a token (e.g. 'sunset') with the parser with a callback function that gets passed the determined date and returns the appropriate time.

Easy example (registering 'midnight' as a token):

date.register('midnight', function(d) { return d.setHours(0, 0, 0) });

I know 'midnight' already exists, but it's just an example. This feature could also make 'evening', 'night', and so on more dynamic and user customizable.

Thanks.

@matthewmueller
Copy link
Owner

+1, accepting PRs :-)

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