Why doesn't time.Weekday follow ISO 8601?

1,117 views
Skip to first unread message

michael....@googlemail.com

unread,
Sep 5, 2013, 11:33:37 AM9/5/13
to golan...@googlegroups.com
Currently time.Weekday is declared as follows:

// A Weekday specifies a day of the week (Sunday = 0, ...).
type Weekday int

const (
Sunday Weekday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
)

Sunday is declared as first day of week which is not accoding to the ISO 8601 standard that places monday as the first day of week.
A modification would also make some conversion code in time.ISOWeek() obsolete.

regards,
Michael

Andy Balholm

unread,
Sep 5, 2013, 11:58:58 AM9/5/13
to golan...@googlegroups.com, michael....@googlemail.com
On Thursday, September 5, 2013 8:33:37 AM UTC-7, michael....@googlemail.com wrote:
Sunday is declared as first day of week which is not accoding to the ISO 8601 standard that places monday as the first day of week.
A modification would also make some conversion code in time.ISOWeek() obsolete.

I don't care what ISO says. Sunday is historically the first day of the week. History is as good a standard as some international committee.

Jeremy Wall

unread,
Sep 5, 2013, 12:00:54 PM9/5/13
to Andy Balholm, golang-nuts, michael....@googlemail.com
+1 What could possibly motivate making monday the first day? 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Michael Banzon

unread,
Sep 5, 2013, 12:01:54 PM9/5/13
to Andy Balholm, golang-nuts, michael....@googlemail.com
The starting day of the week (along with starting week number of the year) would depend on what part of the world you ask.

This is why a ISO standard is good for reference - to stop silly discussions about culture and history.


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael Banzon
http://michaelbanzon.com/

egon

unread,
Sep 5, 2013, 12:07:12 PM9/5/13
to golan...@googlegroups.com, michael....@googlemail.com

Henrik Johansson

unread,
Sep 5, 2013, 12:11:36 PM9/5/13
to egon, michael....@googlemail.com, golang-nuts

Historically it should make sense that Monday is the first day what with the seventh day being the day of rest... Just saying ;-)

egon

unread,
Sep 5, 2013, 12:23:02 PM9/5/13
to golan...@googlegroups.com, michael....@googlemail.com
This can't be modified due to Go compatibility guarantee. http://golang.org/doc/go1compat.html

I'm not able to access the actual ISO standard, but http://www.cl.cam.ac.uk/~mgk25/iso-time.html says that the day counting starts from "1" ("A week starts with Monday (day 1)", so only Sunday value seems to be "wrong".

+ egon

Andy Balholm

unread,
Sep 5, 2013, 12:47:28 PM9/5/13
to golan...@googlegroups.com, egon, michael....@googlemail.com
On Thursday, September 5, 2013 9:11:36 AM UTC-7, Henrik Johansson wrote:

Historically it should make sense that Monday is the first day what with the seventh day being the day of rest... Just saying ;-)

That's probably why it got changed in some countries. Some people likely wanted Sunday to be the seventh day so that it would be the sabbath. But that's just as wrong as the missionaries who translated "sabbath" into Chinook jargon as "Sunday". 

The places I've run into where Monday is considered the first day of the week are Spanish-speaking. But the Spanish word for Saturday gives away the fact that it's really the sabbath, and thus the seventh day: "sabado".

P.S. I am not a Seventh-Day Adventist—even if I sound like one today. :-)

Konstantin Khomoutov

unread,
Sep 5, 2013, 1:03:03 PM9/5/13
to Andy Balholm, golan...@googlegroups.com, egon, michael....@googlemail.com
On Thu, 5 Sep 2013 09:47:28 -0700 (PDT)
Andy Balholm <andyb...@gmail.com> wrote:

> > Historically it should make sense that Monday is the first day what
> > with the seventh day being the day of rest... Just saying ;-)
> >
> That's probably why it got changed in some countries. Some people
> likely wanted Sunday to be the seventh day so that it would be the
> sabbath. But that's just as wrong as the missionaries who translated
> "sabbath" into Chinook jargon as "Sunday".
>
> The places I've run into where Monday is considered the first day of
> the week are Spanish-speaking. But the Spanish word for Saturday
> gives away the fact that it's really the sabbath, and thus the
> seventh day: "sabado".

In Russia (where I live), Monday is also the first day of week for as
long as I can remember. I mean, I do not think I ever managed to came
across any document which stated there were times when we had Sunday
the first day of our weeks. Honestly, I have always thought only USA
had Sunday as the first day of week (as well as being a holdout of
imperial measures as opposed to SI ones).

Ibrahim M. Ghazal

unread,
Sep 5, 2013, 1:20:19 PM9/5/13
to Konstantin Khomoutov, Andy Balholm, michael....@googlemail.com, egon, golan...@googlegroups.com


On 5 Sep 2013 20:03, "Konstantin Khomoutov" <flat...@users.sourceforge.net> wrote:
> Honestly, I have always thought only USA
> had Sunday as the first day of week (as well as being a holdout of
> imperial measures as opposed to SI ones).

Some countries start their week on Sunday (weekend is Friday/Saturday), while others start on Saturday! (weekend is Thursday/Friday). I have personally lived in two such countries.

John Nagle

unread,
Sep 5, 2013, 2:22:51 PM9/5/13
to golan...@googlegroups.com
On 9/5/2013 8:33 AM,
michael....@googlemail.com wrote:
> Currently time.Weekday is declared as follows:
>
> // A Weekday specifies a day of the week (Sunday = 0, ...).

That's because Go was designed by old C people. The "tm"
structure in the old C library designed in the 1970s, when
US programmers never thought about internationalization,
has Sunday as 0.

Python's "date" object has both ".weekday()" (which has
the same values as C) and ".isoweekday()" which follows
ISO 8601.

Javascript's getDay function is, like C, 0..6, Sunday=0.

Java's "java.util.Calendar" type is locale-driven and
very general. Here's the documentation:

http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html

John Nagle


Andy Balholm

unread,
Sep 5, 2013, 3:44:28 PM9/5/13
to golan...@googlegroups.com, Andy Balholm, egon, michael....@googlemail.com
On Thursday, September 5, 2013 10:03:03 AM UTC-7, Konstantin Khomoutov wrote:
In Russia (where I live), Monday is also the first day of week for as
long as I can remember.  I mean, I do not think I ever managed to came
across any document which stated there were times when we had Sunday
the first day of our weeks.

When I talk about history here, I'm not talking about the last few centuries. I hadn't been aware that Russia starts the week on Monday, but now I found this information online: 

When saints Cyril and Methodius brought Christianity to the Slavs, they took on the Greek tradition of numbering the days, but they numbered them from Monday instead of Sunday. (http://www.cjvlang.com/Dow/SunMon.html )

So as far as the history of Russia is concerned, Monday has always been the first day of the week. But the week is a lot older than Russia. :-) And until about 1500 years ago, there seems to have been little question that it started on Sunday.

Brad Fitzpatrick

unread,
Sep 5, 2013, 4:18:38 PM9/5/13
to michael....@googlemail.com, golang-nuts
Mnemonic: Sunday is 0 because there's zero agreement about what it should be.
 


--

Svip

unread,
Sep 5, 2013, 4:20:30 PM9/5/13
to Brad Fitzpatrick, michael....@googlemail.com, golang-nuts
On 5 September 2013 22:18, Brad Fitzpatrick <brad...@golang.org> wrote:

> Mnemonic: Sunday is 0 because there's zero agreement about what it should
> be.

In crontab, Sunday is both 0 and 7 as a compromise. You could extend
time.Weekday() like that.

Brad Fitzpatrick

unread,
Sep 5, 2013, 4:23:16 PM9/5/13
to Svip, michael....@googlemail.com, golang-nuts
Sounds good. First we'll have to add Perl 6 Junctions to Go.


Svip

unread,
Sep 5, 2013, 4:27:48 PM9/5/13
to Brad Fitzpatrick, michael....@googlemail.com, golang-nuts
To be quite honest, I don't really give a damn. In my country, Monday
is the first day of the week, because it is the more practical, as the
weekend is Saturday and Sunday, and it's nice to have 'weekend' being
*the* end. In German, the word for Wednesday literally means 'week
middle', but it is not in the middle anymore, because in Germany,
Monday is the first day of the week (as it is in most of Europe).

It's the same reason January is the first month of the year; for
management reasons. Makes more sense that we start working as soon as
a new week begins. Hell, it's why we use metric for measuring and
volumes, because it's just more practical.

If history is supposed to be a guideline, Go shouldn't even be using
the Gregorian Calendar.

Kamil Kisiel

unread,
Sep 5, 2013, 4:30:38 PM9/5/13
to golan...@googlegroups.com, Brad Fitzpatrick, michael....@googlemail.com
Great, then we can do:

 if day := time.Weekday(); day == time.Sunday || time.OtherSunday { 

}

Kamil Kisiel

unread,
Sep 5, 2013, 4:31:41 PM9/5/13
to golan...@googlegroups.com
Of course I meant day == time.OtherSunday there 

Svip

unread,
Sep 5, 2013, 4:37:16 PM9/5/13
to Kamil Kisiel, golan...@googlegroups.com
I would propose to call it 'BetterSunday', but it works for me.

What will Go do when we decide to extend weeks to 9 days?

Dan Kortschak

unread,
Sep 5, 2013, 4:37:30 PM9/5/13
to John Nagle, golan...@googlegroups.com
In that case Monday is the first day of the week; Sunday is the zeroth day.

Svip

unread,
Sep 5, 2013, 4:39:13 PM9/5/13
to Dan Kortschak, John Nagle, golan...@googlegroups.com
On 5 September 2013 22:37, Dan Kortschak <dan.ko...@adelaide.edu.au> wrote:

> In that case Monday is the first day of the week; Sunday is the zeroth day.

Yeah, that's not really how ordinal numbers work. There is not a
zeroth anything; it's always first. If something is 0-indexed, [0] is
still the first element. Ordinal, cardinal.

Unless you were making a joke, in which case I'll excuse myself.

Dan Kortschak

unread,
Sep 5, 2013, 4:43:51 PM9/5/13
to Svip, John Nagle, golan...@googlegroups.com
That's, OK.

Brad Fitzpatrick

unread,
Sep 5, 2013, 4:48:58 PM9/5/13
to Dan Kortschak, Svip, John Nagle, golan...@googlegroups.com
Did you hear about the guy who got frozen to absolute zero?  He's 0K now.



That's, OK.

egon

unread,
Sep 6, 2013, 12:31:35 AM9/6/13
to golan...@googlegroups.com, Andy Balholm, egon, michael....@googlemail.com
After researching more about Sumerian week than I care to admit, I've come to the following understanding (which could be absolutely wrong). Essentially the day names and use of week is from Sumerian week ~2500BC (http://www.economist.com/node/895542?fsrc=scn/fb/wl/ar/thepowerofseven), although the article listed Babylonian gods used, but not the Sumerian, luckily there are several sources doing that (e.g. http://community.qlikview.com/blogs/qlikviewdesignblog/2012/10/23/ancient-gods). Nanna/Sin was the god of moon [Monday] and considered as the head of the pantheon (http://en.wikipedia.org/wiki/Sin_(mythology)) and whose child was Utu/Shamash (god of sun [Sunday] ). This would suggest "the god of moon" would precede and be more important than "the god of sun". :)

+ egon
Reply all
Reply to author
Forward
0 new messages