GithubHelp home page GithubHelp logo

Comments (2)

alanjames1987 avatar alanjames1987 commented on June 16, 2024

I've always dealt with timezones client side before passing the dates to ui modules. This is because there is so much work in dealing with timezones and every company I have worked for has dealt with them differently.

I will refer you to this video to hopefully entertain while also talking illustrating why dealing with timezones is a pain.

https://www.youtube.com/watch?v=-5wpm-gesOY

If you have any suggestions about how this module should deal with them please suggest. I am more than willing to add something if it is warranted.

from ng-bs-daterangepicker.

divan avatar divan commented on June 16, 2024

You're right, timezones are tricky, and that's, actually, the point in case of _date_rangepicker - we don't need timezones at all here. Correct me if I'm wrong, but use case for date range picker is to handle date ranges - say, when you book a hotel. We don't work with exact timestamps (well, maybe check-in/check-out times need to be specified, but that's more of application level logic).

If I select range "Sep 10 - Oct 10 ", I want exactly this date range to be stored and shown to all clients, regardless of their timezone. That fact that 'Sep 10 00:00:00' in my timezone is 'Sep 09 18:00:00' in another timezone should be irrelevant to date range picker.

My suggestion would be to always store startDate and endDate as UTC with 00:00:00 time, but it would be backward incompatible with people who use it already. So I'd suggest to make new option, something like 'utc' or 'forceUTC' and implement it this way, stepping out of time/timezone calculations completely and let user deal with their particular case.

Currently I use this ugly code to get 'correct' date timestamp:

var end = $scope.dateRange.endDate.toDate();
year = 1900 + end.getYear();
month = end.getMonth();
day = end.getDate();
var end_date = new Date(Date.UTC(year, month, day, 12, 00, 00));

But it's kinda sad :)

from ng-bs-daterangepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.