Hi,

I can see at least two possible ways here:
  1. some code I found by googling:
    Use some code like the following (found here: http://www.merlyn.demon.co.uk/programs/what-cw.pl):
    #!/usr/local/bin/perl if (@ARGV != 3) { print "usage: $0 <day> <month> <year>\n"; exit; } ($day, $month, $year) = @ARGV; ($cw, $y) = calendarWeek($day, $month, $year); print "CW = $cw (in year $y)\n"; exit; #===================================================================== += # subroutines #===================================================================== += #--------------------------------------------------------------------- +- # julianDay() # # calculates the Julian Day, as described in the "Calendar FAQ" # (http://www.pauahtun.org/CalendarFAQ/cal/calendar24.html, section 2. +15.1) # #--------------------------------------------------------------------- +- sub julianDay { my ($day, $month, $year) = @_; my ($a, $y, $m); $a = int((14 - $month)/12); $y = $year + 4800 - $a; $m = $month + 12 * $a - 3; my $jd = $day + int((153 * $m + 2)/5) + 365 * $y + int($y/4) - int($y/100) + int($y/400) - 32045; return $jd; } #--------------------------------------------------------------------- +- # calendarWeek() # # returns an array consisting of calendar-week and year, where year # is the year in which the calendar-week actually falls #--------------------------------------------------------------------- +- sub calendarWeek { my ($day, $month, $year) = @_; my $jd = julianDay($day, $month, $year); my($d1, $d4, $l); $d4 = ($jd + 31741 - ($jd % 7)) % 146097 % 36524 % 1461; $l = int($d4/1460); $d1 = (($d4 - $l) % 365) + $l; my $cw = int($d1/7) + 1; if (($month == 1) && ($cw > 51)) { $year--; } elsif (($month == 12) && ($cw == 1)) { $year++; } return ($cw, $year); }
  2. Install modules somewhere, where you have write access, for example in your homedirectory or somewhere else. You then just need to tell your Perl program where to find those modules:
    1. Get the module (e.g. Date::Calc) from CPAN, untar it into a temporary folder and cd into the directory
    2. Issue the following commands:
      % perl Makefile.PL PREFIX=/home/USERNAME/perl-site # set your path acc +ordingly % make % make test % make install % make clean
    3. then, at the beginning of your program, "add" the module to your Perl distribution by adding the following line:
      use lib qw( /home/USERNAME/perl-site );
    hth,
    Sven

    In reply to Re: ISO Date Week Number by svenXY
    in thread ISO Date Week Number by Anonymous Monk

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  3. Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  4. Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  5. Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  6. Please read these before you post! —
  7. Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  8. You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  9. Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  10. See Writeup Formatting Tips and other pages linked from there for more info.