in reply to Re^2: Date::Format handling of ISO week number format
in thread Date::Format handling of ISO week number format

Ah, well that sucks. I would file a bug report. Since that doesn't work, I shall return to my first idea, which is to use Date::Calc. I didn't even know about Date::Format until you pointed it out.

#! /usr/local/bin/perl -w use strict; use Date::Calc 'Week_of_Year'; my ($y, $m, $d) = split m{/}, shift || '2007/12/31'; my ($week,$year) = Week_of_Year($y, $m, $d); printf "%04d-W%02d\n", $year, $week;

You might want to wrap that up in a little routine and be done with it. It will certainly be far faster than using Date::Manip

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^4: Date::Format handling of ISO week number format
by Oberon (Monk) on Jan 16, 2008 at 23:48 UTC
    That's a good idea, grinder. It won't be quite as easy as just writing a routine, since I have to be able to handle any given format coming in, but I think I can hack something together. Just scan the format for either %L or %W and, if I see either one, call Week_of_Year and do the substitution myself. Then I can pass it off to time2str if there are any %'s left.

    Not super elegant, perhaps, but definitely workable. Thanx!