Author: wlux
Date: Mon Nov 28 10:01:04 2016
New Revision: 40239
URL: http://svn.gna.org/viewcvs/gnustep?rev=40239&view=rev
Log:
Fix an off by 1 calculation which meant that weekOfYear would return 2
for the first week of a year whenever the first Thursday of that year
is 7 Jan, for instance 2016.
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/Additions/NSCalendarDate+GNUstepBase.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=40239&r1=40238&r2=40239&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Mon Nov 28 10:01:04 2016
@@ -1,3 +1,10 @@
+2016-11-28 Wolfgang Lux <[email protected]>
+
+ * Source/Additions/NSCalendarDate+GNUstepBase.m (weekOfYear): Fix
+ an off by 1 calculation which meant that weekOfYear would return 2
+ for the first week of a year whenever the first Thursday of that
+ year is 7 Jan, for instance 2016.
+
2016-11-10 Richard Frith-Macdonald <[email protected]>
* Source/NSPortCoder.m:
Modified: libs/base/trunk/Source/Additions/NSCalendarDate+GNUstepBase.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/Additions/NSCalendarDate%2BGNUstepBase.m?rev=40239&r1=40238&r2=40239&view=diff
==============================================================================
--- libs/base/trunk/Source/Additions/NSCalendarDate+GNUstepBase.m
(original)
+++ libs/base/trunk/Source/Additions/NSCalendarDate+GNUstepBase.m Mon Nov
28 10:01:04 2016
@@ -89,8 +89,10 @@
/*
* Round up to a week boundary, so that when we divide by seven we
* get a result in the range 1 to 53 as mandated by the ISO standard.
+ * Note that dayOfYear starts at 1, too, and hence we must be careful
+ * to not round up an exact multiple of 7.
*/
- dayOfYear += (7 - dayOfYear % 7);
+ dayOfYear += (7 - (dayOfYear - 1) % 7);
return dayOfYear / 7;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs