mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
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. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40239 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
34359ff25f
commit
80a0d3f28d
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2016-11-28 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* 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 <rfm@gnu.org>
|
||||
|
||||
* Source/NSPortCoder.m:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue