head 1.2; access; symbols pkgsrc-2014Q3:1.1.0.44 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.42 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.40 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.38 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.36 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.34 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.32 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.30 pkgsrc-2012Q4-base:1.1 pkgsrc-2012Q3:1.1.0.28 pkgsrc-2012Q3-base:1.1 pkgsrc-2012Q2:1.1.0.26 pkgsrc-2012Q2-base:1.1 pkgsrc-2012Q1:1.1.0.24 pkgsrc-2012Q1-base:1.1 pkgsrc-2011Q4:1.1.0.22 pkgsrc-2011Q4-base:1.1 pkgsrc-2011Q3:1.1.0.20 pkgsrc-2011Q3-base:1.1 pkgsrc-2011Q2:1.1.0.18 pkgsrc-2011Q2-base:1.1 pkgsrc-2011Q1:1.1.0.16 pkgsrc-2011Q1-base:1.1 pkgsrc-2010Q4:1.1.0.14 pkgsrc-2010Q4-base:1.1 pkgsrc-2010Q3:1.1.0.12 pkgsrc-2010Q3-base:1.1 pkgsrc-2010Q2:1.1.0.10 pkgsrc-2010Q2-base:1.1 pkgsrc-2010Q1:1.1.0.8 pkgsrc-2010Q1-base:1.1 pkgsrc-2009Q4:1.1.0.6 pkgsrc-2009Q4-base:1.1 pkgsrc-2009Q3:1.1.0.4 pkgsrc-2009Q3-base:1.1 pkgsrc-2009Q2:1.1.0.2 pkgsrc-2009Q2-base:1.1; locks; strict; comment @# @; 1.2 date 2014.11.20.16.11.50; author wiz; state dead; branches; next 1.1; commitid 31rlNUGdef7MpWYx; 1.1 date 2009.04.16.09.54.45; author he; state Exp; branches; next ; desc @@ 1.2 log @Remove patch-ad, gone from distinfo. @ text @$NetBSD: patch-ad,v 1.1 2009/04/16 09:54:45 he Exp $ Fix this so that it uses week numbering according to ISO 8601. --- weekno.perl.orig 1995-10-17 14:44:49.000000000 +0100 +++ weekno.perl @@@@ -51,7 +51,21 @@@@ sub weekno { sub firstdayfirstweek { -# Return first day of week 1 of any year +# Return the day of the year (0 is Jan 1st) +# for the first day of week 1 of any year. +# +# Quoting strftime(3): +# %V is replaced by the week number of the year (Monday as the first day +# of the week) as a decimal number [01,53]. According to ISO 8601 the +# week containing January 1 is week 1 if it has four or more days in +# the new year, otherwise it is week 53 of the previous year, and the +# next week is week 1. The year is given by the `%G' conversion +# specification. +# +# So this will return a negative value in some cases, i.e. when +# Jan 1st falls on either of Tuesday, Wednesday or Thursday, and +# will be positive (1) or zero for Sunday or Monday respectively. +# local($y) = @@_; local($ret); # Get time of January 1, 0.0.0.0 @@@@ -59,13 +73,14 @@@@ sub firstdayfirstweek { local($firsttime) = &main'timelocal(0, 0, 0, 1, 0, $y, 0, 0, 0); local(@@firstday) = localtime($firsttime); local($wday) = $firstday[6]; - # Rule works for some years.....89 to 92 tested, they all hit branch 2... - if ($wday > 3) { - $ret = 8 - $wday; + # Weekday 4 is Thursday (localtime returns zero-based with Sunday = 0) + if ($wday <= 4) { + $ret = 1 - $wday; # first day of week 1 may be in late December + # The exception is when Jan 1 = Sunday (wday 0) } else { - $ret = 1 - $wday; + $ret = 8 - $wday; # first day of week 1 is in January } - $ret; + return $ret; } sub firstinweek { @ 1.1 log @Update from version 1.98nb3 to 1.98nb4. Pkgsrc changes: o Add a fix to ensure this operates with week numbers in accordance with ISO 8601. @ text @d1 1 a1 1 $NetBSD$ @