Mark Martinec wrote:
> Michael,
>
>
>> I am looking for perl, php and mysql functions to produce the exact same
>> iso week number (yes, there are 7 modes of this, based on my research)
>>
>> the custom iso_week() function seems to be the same if not exactly the
>> same as mysql WEEK(time,3) (mode 3), and for that matter, the same as
>> DateTime.pm.
>> (first week of year is first week with a thursday in it, or, first week,
>> starting on monday with 4 or more days..., so dec 28, 2008 is year 2008,
>> week 52, jan 1, 2009 is year 2008, week 52 )
>>
>
> Yes, it is indeed equivalent to MySQL week(date,3), as documented in the code:
>
> # Given a Unix numeric time (seconds since 1970-01-01T00:00Z),
> # provide a week number 1..53 (local time) as specified in ISO 8601 (EN 28601)
> # ( equivalent to PostgreSQL extract(week from ...), and MySQL week(date,3) )
> #
> sub iso8601_week($) { ... }
>
>
anyone doing partitioning and need iso YEARWEEK?
I am also testing a variation of iso_week (iso_year) so I can get the 4
digit ISO year (which isn't the calender year), esp on jan 1st, 2009.. :-)
if there is any value to that, you can have it back for amavisd 2.6x.
else, I'll just tack it onto amavisd.conf.
I think this does it (just a hack of your iso8601_week(). returns
yyyyww (same as mysql yearweek(,3)
given a julian time (seconds since jan 1, 1970)
sub iso8601_yearweek($) {
my($unix_time) = @_;
my($y,$dowm0,$doy0) = (localtime($unix_time))[5,6,7];
$y += 1900; $dowm0--; $dowm0=6 if $dowm0<0; # normalize, Monday==0
my($dow0101) = ($dowm0 - $doy0 + 53*7) % 7; # dow Jan 1
my($wn) = int(($doy0 + $dow0101) / 7);
if ($dow0101 < 4) { $wn++ }
if ($wn == 0) { $wn = iso8601_year_is_long($y-1) ? 53 : 52 }
elsif ($wn == 53 && !iso8601_year_is_long($y)) { $wn = 1; $y++ }
<---- here is only change I thought was needed, the $y++ if ! long year.
sprintf("%d%2.2d",$y,$wn);
}
_________________________________________________________________________
This email has been scanned and certified safe by SpammerTrap(r).
For Information please see http://www.secnap.com/products/spammertrap/
_________________________________________________________________________
_________________________________________________________________________
This email has been scanned and certified safe by SpammerTrap(r).
For Information please see http://www.spammertrap.com
_________________________________________________________________________
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/