wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
899 stars 132 forks source link

timestamp() method modifies time #202

Closed ajaxovic closed 3 years ago

ajaxovic commented 3 years ago

Method datetime.timestamp() returns time always at 00:00

I have a code:

let endDate = new Date();
endDate.setHours(23,59,59,999);

const picker = new Litepicker({
    element: document.getElementById('litepicker'),
        endDate: endDt,
        ...
});

let endDt = picker.getEndDate();
console.log(endDt.toJSDate());
console.log(new Date(endDt.timestamp()));

Output looks like this:

Fri Mar 05 2021 23:59:59 GMT+0100 (Central European Standard Time)
Fri Mar 05 2021 00:00:00 GMT+0100 (Central European Standard Time)

In my point of view, returned timestamp should not be forced to start of day. Please, consider to fix it and thank you for your work.

wakirin commented 3 years ago

use endDt.toJSDate().getTime()

ajaxovic commented 3 years ago

Ah, ok, it works. It was confusing for me, I just found method timestamp() in code and use it. Maybe some little page about datetime in doc? :)

Again, thank you for this great library

wakirin commented 3 years ago

Maybe some little page about datetime in doc? :)

Yes, I will add a page about DateTime soon.