Author Topic: Wrong week calculation  (Read 760 times)

0 Members and 1 Guest are viewing this topic.

rabol

  • Guest
Wrong week calculation
on: Wed, 10. July 2002 - 20:54:00
Hi

I think that vlibDate retuns the wrong week
eg:
$week = $vdate->weekOfYear($vdate->mkTimestamp ("2002","06","10"));

then $week is 23 which is incorrect according to my calendar it's week 24.
PHP function date() returns this:

$week = date("W", mktime(0,0,0,"06","10","2002"));

$week is now 24

Best
Steen

releasedj

  • Guest
Wrong week calculation
Reply #1 on: Wed, 10. July 2002 - 21:55:00
This is the desired result.

vlibDate::weekOfYear() returns the week of the year with the first sunday of the year being the first week.

I will be adding a second parameter to the function which, when it's true, will use the first monday of the year as the first week. This will give you the result that you need.

i.e. vlibDate::weekOfYear('2002-06-10', true); // will return 24

Sign up to the mailing list to be updated of this release.

Many thanks,

Kelvin

[size=8][ This Message was edited by: releasedj on 2002-07-10 21:56 ][/size]

releasedj

  • Guest
Wrong week calculation
Reply #2 on: Tue, 16. July 2002 - 10:53:00
With vLIB 3.0.4, vlibDate::weekOfYear() now supports a second argument that causes the first day of the first week of the year to start on the first Monday of the year.

Regards,

Kelvin