Covert Date to week number

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

  1. #1

    Default Covert Date to week number

    Is their a way in PERL to covert a date to a week number


    Cheers

    Neill





    ********************
    IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments.

    Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as "TM Group"). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices.

    Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP.
    ********************
    Neill Taylor 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. Convert Date to week number
      Tim wrote: ISO8601 defines a standard, but not everyone follows it. See: ...
    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: Covert Date to week number

    > -----Original Message-----
    > From: [email]neill.taylor@trinityst.co.uk[/email]
    > [mailto:neill.taylor@trinityst.co.uk]
    > Sent: Thursday, January 22, 2004 11:28 AM
    > To: [email]beginners@perl.org[/email]
    > Subject: Covert Date to week number
    >
    >
    > Is their a way in PERL to covert a date to a week number
    >
    >
    > Cheers
    >
    > Neill
    Date::Calc has what you're looking for -> Week_of_Year()
    Luke Bakken Guest

  4. #3

    Default RE: Covert Date to week number

    >
    > Is their a way in PERL to covert a date to a week number
    >
    Sure , why not? You'd need to know the date format to start of course.
    I don't mess with dates personally a lot so I'd say have
    a look on search.cpan.org for a module to do that.

    Also perldoc may be able to help you.

    Sorry to be so vague, just wanted to givve you a place to start looking.

    DMuey
    >
    > Cheers
    >
    > Neill
    Dan Muey Guest

  5. #4

    Default RE: Covert Date to week number


    Check out Time::Local. It makes it easy to break down a formatted date
    field and put it into Perl time format.

    -----Original Message-----
    From: [email]neill.taylor@trinityst.co.uk[/email] [mailto:neill.taylor@trinityst.co.uk]

    Sent: Thursday, January 22, 2004 11:28 AM
    To: [email]beginners@perl.org[/email]
    Subject: Covert Date to week number

    Is their a way in PERL to covert a date to a week number


    Tim Johnson Guest

  6. #5

    Default Re: Covert Date to week number

    On Thu, 22 Jan 2004 19:28:24 +0000
    [email]neill.taylor@trinityst.co.uk[/email] wrote:
    > Is their a way in PERL to covert a date to a week number
    >
    Try this;


    #!/usr/bin/perl
    use Date::Calc qw(Week_Number Week_of_Year);

    @t=localtime;

    $week = Week_Number($t[5]+1900,$t[4]+1,$t[3]); #Deprecated
    print " From Date::Calc Week Number is $week \n";

    ($week,$year) = Week_of_Year($t[5]+1900,$t[4]+1,$t[3]); #Preferred
    print " From Date::Calc Week of Year is $week \n";






    > Cheers
    >
    > Neill
    >
    >
    >
    >
    >
    > ********************
    > IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments.
    >
    > Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as "TM Group"). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices.
    >
    > Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP.
    > ********************
    >
    > --
    > To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    > For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >

    --
    Owen

    Owen Guest

  7. #6

    Default [meta] Please delete boilerplate! (was Re: Covert Date to week number)

    >>>>> "Neill" == Neill Taylor <neill.taylor@trinityst.co.uk> writes:

    Neill> Is their a way in PERL to covert a date to a week number
    Neill> Cheers

    Neill> Neill

    Neill> ******************** IMPORTANT NOTICE This email (including any
    Neill> attachments) is meant only for the intended recipient. It may
    Neill> also contain confidential and privileged information. If you
    Neill> are not the intended recipient, any reliance on, use,
    Neill> disclosure, distribution or copying of this email or
    Neill> attachments is strictly prohibited. Please notify the sender
    Neill> immediately by email if you have received this message by
    Neill> mistake and delete the email and all attachments.

    Neill> Any views or opinions in this email are solely those of the
    Neill> author and do not necessarily represent those of Trinity Mirror
    Neill> PLC or its associated group companies (hereinafter referred to
    Neill> as "TM Group"). TM Group accept no liability for the content of
    Neill> this email, or for the consequences of any actions taken on the
    Neill> basis of the information provided, unless that information is
    Neill> subsequently confirmed in writing. Although every reasonable
    Neill> effort is made to keep its network free from viruses, TM Group
    Neill> accept no liability for any virus transmitted by this email or
    Neill> any attachments and the recipient should use up-to-date virus
    Neill> checking software. Email to or from this address may be subject
    Neill> to interception or monitoring for operational reasons or for
    Neill> lawful business practices.

    Neill> Trinity Mirror PLC is the parent company of the Trinity Mirror
    Neill> group of companies and is registered in England No 82548, with
    Neill> its address at One Canada Square, Canary Wharf, London E14 5AP.
    Neill> ********************

    Let's see the stats:

    Number of lines of original question: 1
    Number of lines of closing salutation: 1
    Number of lines of sig: 2

    Number of lines of COMPLETELY USELESS LEGAL DISCLAIMER: 27 lines after wrapping

    Here's my boilerplate to reply to your boilerplate:

    You have exceeded the 4-line .sig boilerplate limit with a worthless
    unenforcable disclaimer. Please remove this text from future postings
    to this mailing list. If you cannot do so for mail from your domain,
    please get a freemail account and rejoin the list from there.

    And I do this publicly so that it goes into the archives, so others
    will also see that people *do* object to these things, and that there
    *is* a ready solution to it.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

  8. #7

    Default Re: Convert Date to week number

    Neill Taylor wrote:
    >
    > Is their a way in PERL to covert a date to a week number
    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?)

    BTW I agree wholeheartedly with Randal. He may be a Yank but he's
    not all bad :) I'm surprised the Mirror legaloids can be such
    idiots. Sometimes I wish I could be anational instead of being
    branded with rubbish like this. At least I read the Independent
    instead!

    Rob


    Rob Dixon Guest

  9. #8

    Default Re: Convert Date to week number

    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

    Tim Guest

  10. #9

    Default Re: Convert Date to week number

    Timwrote:
    >
    > 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?)
    >
    > 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?
    I got this from the British 'Letts' diary manufacturer about ten years back.
    Clearly it makes sense, as a week is, usefully, an odd number of days long
    and can be assigned into either one year or the other. The big difference
    is on which day a week starts, which is both nationally and culturally
    variant.

    Rob


    Rob Dixon Guest

  11. #10

    Default Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

    Unfortunately, if the person is writing from work, the disclaimer is
    likely required by his employer. I know that I have a similar one at work.
    And not including it is grounds for termination <stupid>.

    The only way around this is to use a personal email, like I do. But he may
    need the help for work and at work. Supposedly, I cannot use my personal
    email from work. But I know ways and means around it and am stealthy
    enough that I am not likely to get caught.

    I'm sitting at work now, but using my home email.

    --
    Maranatha!
    John McKown


    John McKown Guest

  12. #11

    Default Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

    Except that John's boss is on the list too!

    On Fri, 2004-01-23 at 14:37, John McKown wrote:
    > Unfortunately, if the person is writing from work, the disclaimer is
    > likely required by his employer. I know that I have a similar one at work.
    > And not including it is grounds for termination <stupid>.
    >
    > The only way around this is to use a personal email, like I do. But he may
    > need the help for work and at work. Supposedly, I cannot use my personal
    > email from work. But I know ways and means around it and am stealthy
    > enough that I am not likely to get caught.
    >
    > I'm sitting at work now, but using my home email.
    >
    > --
    > Maranatha!
    > John McKown
    >
    >
    Levon Barker Guest

  13. #12

    Default Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

    On Fri, 23 Jan 2004, Levon Barker wrote:
    > Except that John's boss is on the list too!
    >
    No, my boss is not UNIX or even Windows literate. He is a BOSS, not a
    GRUNT. He may, from years past, remember some COBOL (remember that?). If I
    told him that I was on a Perl list, he would think that I was talking
    about the things that come out of oysters.

    --
    Maranatha!
    John McKown

    John McKown Guest

  14. #13

    Default Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)


    "John McKown" <joarmc@swbell.net> wrote in message
    news:Pine.LNX.4.44.0401231951460.14064-100000@mckown4.johnmckown.net...
    > > Except that John's boss is on the list too!

    I don't know about John's boss but I'm not even on "the list." I'm reading
    this in a newsgroup via GigaNews.


    --
    [url]www.eSnider.net[/url]


    Larry Snider 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