I would like Sunday to be 0, but when using the datetime weeday methods it's 6:
datetime(2013, 6, 9, 11, 59, 59, 1).weekday() # this returns 6
My locale is: "en_US.UTF-8" so Sunday should be 0 (when I run 'locale day' at bash prompt, it correctly shows 'Sunday' as first day of the week).
$ locale day
Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday
How can I get python to show Sunday as the first day of the week?
(I'm using a pandas timeseries and calling .date
to get the datetimes.)
Monday is the first day of the week, according to the international standard for the representation of dates and times ISO 8601. However, in the United States and Canada, Sunday is considered to be the start of the week. This is because of religious reasons.
"For the Jews who write the Bible, Sabbath was celebrated on Saturday meaning Sunday was the beginning of the week," he said. The United States, Canada, most of South America, China, Japan and the Philippines officially consider Sunday to start the week ahead.
For centuries the Romans used a period of eight days in civil practice, but in 321 CE Emperor Constantine established the seven-day week in the Roman calendar and designated Sunday as the first day of the week.
According to the Hebrew calendar and traditional calendars (including Christian calendars) Sunday is the first day of the week; Quaker Christians call Sunday the "first day" in accordance with their testimony of simplicity.
Try this :
(datetime.datetime(2013, 6, 9, 11, 59, 59, 1).weekday() + 1) % 7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With