Calendar yr-mnth-day data to day since data

Discussion in 'Python' started by skorpio11@gmail.com, Oct 3, 2009.

  1. Guest

    Hi all,

    I have some calendar data in three arrays corresponding to yr, month,
    day that I would like to convert to day since data and be consistent
    with changes in leap year. I've included a sample of the data
    structures below. Any suggestions??? Thanks in advance

    yr mnth day daySince
    1970 1 1 1
    1970 1 15 15
    1970 1 28 28
    1970 2 1
    32
    1970 2 27 59
    1970 3 1
    1970 3 4
    1970 3 29
    ... ... ...

    2008 1 1
    2008 1 8
    2008 1 25
    2008 2 1
     
    , Oct 3, 2009
    #1
    1. Advertising

  2. >>>>> "" <> (sc) wrote:

    >sc> Hi all,
    >sc> I have some calendar data in three arrays corresponding to yr, month,
    >sc> day that I would like to convert to day since data and be consistent
    >sc> with changes in leap year. I've included a sample of the data
    >sc> structures below. Any suggestions??? Thanks in advance


    >sc> yr mnth day daySince
    >sc> 1970 1 1 1
    >sc> 1970 1 15 15
    >sc> 1970 1 28 28
    >sc> 1970 2 1
    >sc> 32
    >sc> 1970 2 27 59
    >sc> 1970 3 1
    >sc> 1970 3 4
    >sc> 1970 3 29
    >sc> ... ... ...


    >sc> 2008 1 1
    >sc> 2008 1 8
    >sc> 2008 1 25
    >sc> 2008 2 1


    Days since what? It appears here to be since 1969-12-31, or since
    1970-1-1 but then starting with 1 instead of 0.
    And your 59 is wrong if the others are deemed to be correct.

    Depending on what you want you have to add 1 to the following solution

    import datetime
    startdate = datetime.date(1970, 1, 1)
    enddate = datetime.date(1970,3,1)
    timediff = enddate - startdate
    print timediff.days

    result: 59
    --
    Piet van Oostrum <>
    WWW: http://pietvanoostrum.com/
    PGP key: [8DAE142BE17999C4]
     
    Piet van Oostrum, Oct 3, 2009
    #2
    1. Advertising

  3. Guest

    On Oct 3, 6:35 am, Piet van Oostrum <> wrote:
    > >>>>> "" <> (sc) wrote:

    > >sc> Hi all,
    > >sc> I have some calendar data in three arrays corresponding to yr, month,
    > >sc> day that I would like to convert to day since data and be consistent
    > >sc> with changes in leap year. I've included a sample of the data
    > >sc> structures below.  Any suggestions???  Thanks in advance
    > >sc> yr          mnth            day                 daySince
    > >sc> 1970    1                       1                     1
    > >sc> 1970    1                       15                  15
    > >sc> 1970    1                       28                  28
    > >sc> 1970    2                       1
    > >sc> 32
    > >sc> 1970    2                       27                  59
    > >sc> 1970    3                       1
    > >sc> 1970    3                       4
    > >sc> 1970    3                       29
    > >sc>     ...       ...                        ...
    > >sc> 2008    1                       1
    > >sc> 2008    1                       8
    > >sc> 2008    1                       25
    > >sc> 2008    2                       1

    >
    > Days since what? It appears here to be since 1969-12-31, or since
    > 1970-1-1 but then starting with 1 instead of 0.
    > And your 59 is wrong if the others are deemed to be correct.
    >
    > Depending on what you want you have to add 1 to the following solution
    >
    > import datetime
    > startdate = datetime.date(1970, 1, 1)
    > enddate = datetime.date(1970,3,1)
    > timediff = enddate - startdate
    > print timediff.days
    >
    > result: 59
    > --
    > Piet van Oostrum <>
    > WWW:http://pietvanoostrum.com/
    > PGP key: [8DAE142BE17999C4]


    Thanks ... This module does the trick nicely
     
    , Oct 4, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lars Siden
    Replies:
    0
    Views:
    354
    Lars Siden
    Oct 22, 2003
  2. Andy
    Replies:
    1
    Views:
    755
  3. Parthiv Joshi
    Replies:
    1
    Views:
    805
    Samuel L Matzen
    Jul 6, 2004
  4. Keith-Earl
    Replies:
    3
    Views:
    559
    Keith-Earl
    Oct 26, 2004
  5. Rob Redmon

    Convert day of year to month, day

    Rob Redmon, Apr 4, 2008, in forum: Ruby
    Replies:
    7
    Views:
    339
    Alex Wayne
    Apr 4, 2008
Loading...

Share This Page