Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need Sunday as the first day of the week

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.)

like image 488
user2458008 Avatar asked Jun 10 '13 02:06

user2458008


People also ask

Can Sunday be the first day of the week?

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.

Who uses Sunday as the first day of the week?

"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.

When did Sunday become the first day of the week?

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.

Is Sunday the first day of the week according to the Bible?

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.


1 Answers

Try this :

(datetime.datetime(2013, 6, 9, 11, 59, 59, 1).weekday() + 1) % 7
like image 152
Gauthier Boaglio Avatar answered Oct 07 '22 11:10

Gauthier Boaglio