[mrtg] Re: week numbering

Jerry Heidtke jheidtke at fmlh.edu
Fri Jan 10 00:44:10 MET 2003


More than anyone ever wanted to know about week nummbers...

The "00" being displayed as a week number is correct according to the
"default" ANSI C language specifications. The first day of Week 01 in 2003
is January 6. January 1-5 fall in Week 00. 

strftime has three parameters to determine how week numbers are expressed:
%U is replaced by the week number of the year (Sunday as the first day of
the week) as a decimal number [00,53]. 
%V is replaced by the week number of the year (Monday as the first day of
the week) as a decimal number [01,53]. If the week containing 1 January has
four or more days in the new year, then it is considered week 1. Otherwise,
it is the last week of the previous year, and the next week is week 1. 
%W is replaced by the week number of the year (Monday as the first day of
the week) as a decimal number [00,53]. All days in a new year preceding the
first Monday are considered to be in week 0. 

The WeekFormat option in mrtg simply passes the preferred strftime week
format to rateup.

Note that %W reported week 01 for Jan. 1, 2001, since it was the first
Monday of the year. There was no week 00 according to %W in 2001, and some
people thought that there were problems in their applications when the year
started right off in week 01. In 2002 and 2003, of course, this is not the
case and so other people think something is broken when they see a week 00.

If you don't want to ever see "00" for a week, you could rewrite the program
and set your own (non-)standard. Or you could use the ISO standard (%V). 

According to ISO standards (ISO 8601:1988(E)):

The week in the ISO calendar is defined (sect. 3.27-28 on p. 4) as: 
[a] time-interval of seven days, starting on a Monday and identified by its
ordinal number within a calendar year.

The numbering of the ISO calendar weeks is defined (sect. 4.3.2.2 on pp.
7-8) as: 
[...] the first calendar week of a year is the one that includes the first
Thursday of that year and [...] the last calendar week of a calendar year is
the week immediately preceding the first calendar week of the next year.

Note 4 to this section also mentions: The rule for determining the first
calendar week is equivalent with the rule "the first calendar week is the
week which includes January 4".

Therefore, according to ISO, week 01 of 2003 is from Dec. 30, 2002 to Jan.
5, 2003. There can never be a week 00 according to the standard. There can
be either 52 or 53 weeks in a year.

The ISO rules lead to some "unexpected" date specifications. For example,
one of the supported date formats is 2003-W01-1 (that is "Year 2003, Week
01, Day 1"). This actually refers to Dec. 30, 2002.

%V is defined in POSIX, but not in older versions (pre-C99) of ANSI C. %V
doesn't work on Windows in any case, any language (except maybe something
written with Metrowerks), any version. After all, we can't expect Redmond to
implement international standards in only ten or fiftenn years. Other common
options for strftime that don't work in at least some versions of Windows
are %G, %h, %e, %n, %U, %T, %R and %D. 

I tried the following versions of Perl on Windows:
v5.6.1 built for MSWin32-x86-multi-thread from ActiveState
v5.8.0 built for MSWin32-x86-multi-thread from ActiveState
v5.6.1 built for cygwin-multi
v5.8.0 built for cygwin-multi-64int

This can be tested with the following commands:
perl -e 'use POSIX;' -e 'print strftime("%U",0,0,0,1,0,103);' (returns '00')
perl -e 'use POSIX;' -e 'print strftime("%V",0,0,0,1,0,103);' (returns '  '
on 5.61, '%V' on 5.80)
perl -e 'use POSIX;' -e 'print strftime("%W",0,0,0,1,0,103);' (returns '00')

PHP4 on Windows works the same as perl 5.61.

Years after Y2K, some programmers are still putting date bugs in their
programs because they don't know a) how the calendar works, and b) how their
programming languages work. But mrtg, rateup, and rrdtool are working
correctly.

-----Original Message-----
From: Peter Glanville [mailto:peter_glanville at cuk.canon.co.uk]
Sent: Thursday, January 09, 2003 11:04 AM
To: Koelstra, J. (Jan); mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: week numbering




Read http://www.ee.ethz.ch/~slist/mrtg/msg16311.html
(same topic, same time, last year)

Answer from Tobi was roughly: Week1 starts with the first Monday in
January. Anything before that is not week 1.

I suppose that just leaves the question of whether a week containing Dec31
and Jan1in the middle of it should be labelled week0 or week52!

I tried Weekformat[_]: V and the week numbers vanished for me, too.
I tried %V and the numbers re-appeared (Oops, typo in the reference
manual?). Same week numbers, but the week now starts on a Sunday instead of
Monday.

For the Weekformat command, it's all down to the support from your OS.
(Windoze? - enough said)

Regards
Peter

---------


It's not only RRDtool with 14all that causes wrong weeknumbers:
I am running MRTG 2.9.17 without rrdtool on a Windows NT 4 box, My
graphs show january 1st in week 00 too.
And 'Weekformat[...]: U' causes the weeknumbers to disappear completely.
Other values (V or W) make no difference.

Jan.


-----Original Message-----
From: Peter Glanville [mailto:peter_glanville at cuk.canon.co.uk]
Sent: Thursday, January 09, 2003 4:11 PM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: week numbering




I have Routers2.cgi, and it also does January 1st in week 0 in the
monthly view. Routers2.cgi v2.12 MRTG 2.9.22 Windoze 2kPro

So it is not just 14all.cgi.

Does this have anything to do with 'weekformat' in the reference file?
That points the problem at the OS, so I can easily believe that this is
the cause of my issues.




From: "Brander, Eric" <Eric.Brander at ACS-INC.com>
Sent: Thursday, January 09, 2003 13:30

I'm running 14all 1.1p25 and my week numbering is correct.  Starts at 1
and ends at 52.  This is on Red Hat 8, btw.


-----Original Message-----
From: Greg.Volk at edwardjones.com [mailto:Greg.Volk at edwardjones.com]
Sent: Thursday, January 09, 2003 7:29 AM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: week numbering


}
}Amusingly, my monthly graph shows weeks numbered from 00 to 51, but the
}year changed on the correct day.  ;-) } }I think this is what Greg
meant. } }(version 2.9.22)

Hmmmm...yeah.

But this is actually a real issue. (I didn't realize it until I compared
my work graphs with my home graphs). If you take a look at the week
numbering on the monthly graph at
http://mrtg.gvolk.com/cgi-bin/14all.cgi?log=switch.gvolk.com_fastetherne
t0_1

7&cfg=mrtg.cfg

you'll
see that 2002 ended at week 52 and 2003 started at week 01. However, I
noticed on my work graphs that 2002 ended at week 51, and 2003 started
at week 00. I'm thinking this is a 14all.cgi descrepancy - 14all is
responsible for handing rrdtool the text that gets added to the graphs,
right? I am running version 1.1p17 at work, and 1.1p23 at home. The only
time related item I see in the 14all history log at
http://my14all.sourceforge.net/history.html
between 1.1p17 and 1.1p23 is:

2002-07-13 v1.1p21 - handle Timezone[] setting



-- Attached file removed by Ecartis and put at URL below --
-- Type: application/ms-tnef
-- Size: 1k (1917 bytes)
-- URL : http://www.ee.ethz.ch/~slist/pantomime/34-WINMAIL.DAT


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi





--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



Het ministerie van Sociale Zaken en Werkgelegenheid sluit elke
aansprakelijkheid uit in verband met het niet juist, onvolledig of niet
tijdig overkomen van de informatie in deze e-mail.
Aan dit bericht kunnen geen rechten worden ontleend.

Dit bericht is alleen bestemd voor de geadresseerde. Indien dit bericht
niet voor u bestemd is, verzoeken wij u dit onmiddellijk aan ons te melden
en de inhoud van het bericht te vernietigen.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------------------------------------------

The ministry of Social Affairs and Employment is not liable for any
incorrect or incomplete transmission of the information in this e-mail or
for any delay in its receipt.
This message shall not constitute any obligations.

This message is intended solely for the addressee.
If you have received this message in error, please inform us immediately
and delete its content.

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi





--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi


Confidentiality Notice: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and may contain confidential 
and privileged information.  Any unauthorized review, use, disclosure or 
distribution is prohibited.  If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list