Error in date formatting

Begonnen von Richard, 09 Januar 2018, 23:46:50

Vorheriges Thema - Nächstes Thema

Richard

Hello

I am having problems with toDate().ddmm().  It is returning values that are 1 month ahead of the date value if I pass the time in seconds since 1900.  If I use toDate().eeee() then that day of the week is also for the date one month ahead.  I think the problem is here in ftui function dateFromString:

(m2) ? new Date(70, 1, 1, 0, 0, m2[1], 0)

The Date() function uses a zero based month, so I think that call will add the number of seconds to 1 Feb 1970, not 1 Jan and therefore dates will be one month out if seconds are supplied as the argument. 

I think the correct call should be:

(m2) ? new Date(70, 0, 1, 0, 0, m2[1], 0)

I changed it in my ftui, but I must have a problem with cached files as it didn't change anything (but it should!)  UPDATE:  it now works correctly.

Are there any timing calls that rely on dateFromString (or toDate()) - I found one in handleUpdates, but I can't tell if changing dateFromString is going to break things.  I think that handleUpdates is going to use the text timestamp for that call, so I don't think I have broken anything.

Regards

Richard

setstate

That seems to be a valid remark. Month in date() is really zero based.
I will check this. Do you have an example of a good reading value to reproduce this for me?

setstate