danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

Month() mixing days and months in Dateranges

Open pluc87 opened this issue 3 years ago • 3 comments

Describe the bug When using DateTime on a Daterange series object, month() seems to be looking at days instead of month in the Date strings.

To Reproduce 2. dates = dfd.dateRange({"start":'01/01/2020', freq: '6H', period:300}) 3. dfd.toDateTime(dates).month().print()

Expected behavior All 4*31 first elements are in January, so month() value should be 0 or 1 for the first month of the year

Screenshots as soon as the 2nd of January, month() returns a "1" value, for february ╔═══╤═══╗ ║ 0 │ 0 ║ ╟───┼───╢ ║ 1 │ 0 ║ ╟───┼───╢ ║ 2 │ 0 ║ ╟───┼───╢ ║ 3 │ 0 ║ ╟───┼───╢ ║ 4 │ 1 ║ ╟───┼───╢ ║ 5 │ 1 ║ ╟───┼───╢ ║ 6 │ 1 ║ ╟───┼───╢ ║ 7 │ 1 ║ ╟───┼───╢ ║ 8 │ 2 ║ ╟───┼───╢ ║ 9 │ 2 ║ ╚═══╧═══╝

Desktop (please complete the following information): OS : windows 10 Browser : Firefox 96.0.3 French system

Thank you very much. I just discovered your library and find it very powerful !

pluc87 avatar Feb 04 '22 15:02 pluc87

Describe the bug When using DateTime on a Daterange series object, month() seems to be looking at days instead of month in the Date strings.

To Reproduce 2. dates = dfd.dateRange({"start":'01/01/2020', freq: '6H', period:300}) 3. dfd.toDateTime(dates).month().print()

Expected behavior All 4*31 first elements are in January, so month() value should be 0 or 1 for the first month of the year

Screenshots as soon as the 2nd of January, month() returns a "1" value, for february ╔═══╤═══╗ ║ 0 │ 0 ║ ╟───┼───╢ ║ 1 │ 0 ║ ╟───┼───╢ ║ 2 │ 0 ║ ╟───┼───╢ ║ 3 │ 0 ║ ╟───┼───╢ ║ 4 │ 1 ║ ╟───┼───╢ ║ 5 │ 1 ║ ╟───┼───╢ ║ 6 │ 1 ║ ╟───┼───╢ ║ 7 │ 1 ║ ╟───┼───╢ ║ 8 │ 2 ║ ╟───┼───╢ ║ 9 │ 2 ║ ╚═══╧═══╝

Desktop (please complete the following information): OS : windows 10 Browser : Firefox 96.0.3 French system

Thank you very much. I just discovered your library and find it very powerful !

Thanks for raising this issue, but I can't reproduce your concern. From my end, this works as intended, where month index starts from 0-11 (Jan-Dec).

risenW avatar Feb 10 '22 07:02 risenW

Hi,

I think this is linked to DateRange using "Tolocaldatestring" and hence using the regional parameter of the browser, but datetime not really referring to these regional parameters (from what I understood).

I changed my firefox language to EN-US, and it works currently as it should (I first changed Windows regional parameters and it did not change anything). Yet the fact that this piece of code is handled differently depending on regional parameters is a bit of a concern.

Maybe if you change your browser regional parameters you might be able to reproduce it.

pluc87 avatar Feb 10 '22 07:02 pluc87

Hi,

I think this is linked to DateRange using "Tolocaldatestring" and hence using the regional parameter of the browser, but datetime not really referring to these regional parameters (from what I understood).

I changed my firefox language to EN-US, and it works currently as it should (I first changed Windows regional parameters and it did not change anything). Yet the fact that this piece of code is handled differently depending on regional parameters is a bit of a concern.

Maybe if you change your browser regional parameters you might be able to reproduce it.

Interesting, thanks for this info! I'll investigate and make it generic.

risenW avatar Feb 10 '22 08:02 risenW