search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Bug parsing datetime

Asked by Anonymous
3 years ago.

var bug1 = DayPilot.DateUtil.fromStringSortable("2020-11-18T13:02:26.249-05:00");
var bug2 = DayPilot.DateUtil.fromStringSortable("2020-11-18T13:33:24.38-05:00");

To fix it in the minified version replace

if ("." === v) {
var m = parseInt(e.substring(20, 23));
if (isNaN(m))
throw i;
c.setUTCMilliseconds(m),
p = DayPilot.DateUtil.getTzOffsetMinutes(e.substring(23))
}

with

if ("." === v) {
var m = parseInt(e.substring(20, 19 + e.substring(19).indexOf('-')));
if (isNaN(m))
throw i;
c.setUTCMilliseconds(m),
p = DayPilot.DateUtil.getTzOffsetMinutes(e.substring(19 + e.substring(19).indexOf('-')))
}

Answer posted by Dan Letecky [DayPilot]
3 years ago.

The first date format ("2020-11-18T13:02:26.249-05:00") is supported and it will work fine.

The second date format ("2020-11-18T13:33:24.38-05:00") is not supported at the moment.

To see all available formats, please see:
https://api.daypilot.org/daypilot-date-constructor/

I don't recommend using time zone specifier in your date string. DayPilot works with an idealized timezone and using a time zone specifier will cause the dates to be converted to the GMT base which is not what you want in most cases. See also:
https://api.daypilot.org/daypilot-date-class/

I also don't recommend using DayPilot.DateUtil.fromStringSortable() directly - it's an internal method. Use DayPilot.Date constructor instead.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.