Convert Date to week number

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default RE: Convert Date to week number

    Tim wrote:
    > At 03:16 PM 1/23/04 +0000, you wrote:
    >> ...
    >> Why not write it yourself?
    >>
    >> You need to know:
    >>
    >> - Which day of the week is the 'first'.
    >>
    >> - Which was the first week of the year that had four or more days.
    >> That's week one.
    >>
    >> Then do the sums/arithmetic/math/mathematics/calculations (what /do/
    >> people prefer?)
    >>
    >> .....
    >> Rob
    >
    > This message thread made me curious about just what constitutes the
    > first week of the year. Is there a standard definition or are we
    > making one here?
    >
    > Tim
    ISO8601 defines a standard, but not everyone follows it. See:

    [url]http://www.mcs.vuw.ac.nz/technical/software/SGML/doc/iso8601/ISO8601.html[/url]

    Excerpt:

    "An ordinal date is identified by a given day in a given year. A week is
    identified by its number in a given year. A week begins with a Monday, and
    the first week of a year is the one which includes the first Thursday, or
    equivalently the one which includes January 4."

    Here's January, 2004:

    $ cal 1 2004
    January 2004
    Su Mo Tu We Th Fr Sa
    1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31

    Since weeks start on Monday, the week ending on Sunday, January 4 was week
    1.

    The DateTime family of modules on CPAN supports this standard.
    Bob Showalter Guest

  2. Similar Questions and Discussions

    1. #39912 [NEW]: date('W') returns wrong week number for some dates
      From: pkus at epf dot pl Operating system: windows xp PHP version: 5.2.0 PHP Bug Type: *General Issues Bug description: ...
    2. Date Range from Week Number
      Has anyone ever tried to create a date range from a week number? Here is my scenario: I have a database with a primary key of weekNum. There are...
    3. Code for telling the week number on a specific date
      I've been annoyed that the Date class had no ability to tell which week a certain date fell within. So I created a function that will take any date...
    4. Covert Date to week number
      Is their a way in PERL to covert a date to a week number Cheers Neill
    5. Parsing a date from the week number of a given year from request post
      I'm trying to get the date from a request-query post that contains a year (request("season") and a week number from that year...
  3. #2

    Default Re: Convert Date to week number

    Bob Showalter wrote:
    >
    > ISO8601 defines a standard, but not everyone follows it. See:
    >
    > [url]http://www.mcs.vuw.ac.nz/technical/software/SGML/doc/iso8601/ISO8601.html[/url]
    >
    > Excerpt:
    >
    > "An ordinal date is identified by a given day in a given year. A week is
    > identified by its number in a given year. A week begins with a Monday, and
    > the first week of a year is the one which includes the first Thursday, or
    > equivalently the one which includes January 4."
    >
    > Here's January, 2004:
    >
    > $ cal 1 2004
    > January 2004
    > Su Mo Tu We Th Fr Sa
    > 1 2 3
    > 4 5 6 7 8 9 10
    > 11 12 13 14 15 16 17
    > 18 19 20 21 22 23 24
    > 25 26 27 28 29 30 31
    >
    > Since weeks start on Monday, the week ending on Sunday, January 4 was week
    > 1.
    >
    > The DateTime family of modules on CPAN supports this standard.
    Thanks Bob. It's always nice to have a document to prod.

    Strange though, since
    > A week begins with a Monday
    yet the tabulation starts on Sunday.

    Rob


    Rob Dixon Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139