Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Calendar yr-mnth-day data to day since data

Reply
Thread Tools

Calendar yr-mnth-day data to day since data

 
 
skorpio11@gmail.com
Guest
Posts: n/a
 
      10-03-2009
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
 
Reply With Quote
 
 
 
 
Piet van Oostrum
Guest
Posts: n/a
 
      10-03-2009
>>>>> "(E-Mail Removed)" <(E-Mail Removed)> (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 <(E-Mail Removed)>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
 
Reply With Quote
 
 
 
 
skorpio11@gmail.com
Guest
Posts: n/a
 
      10-04-2009
On Oct 3, 6:35*am, Piet van Oostrum <(E-Mail Removed)> wrote:
> >>>>> "(E-Mail Removed)" <(E-Mail Removed)> (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 <(E-Mail Removed)>
> WWW:http://pietvanoostrum.com/
> PGP key: [8DAE142BE17999C4]


Thanks ... This module does the trick nicely
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Now.day and day(now) returning the wrong day! Andy ASP .Net 1 11-06-2008 12:20 PM
Re: On the 15th Day of The Hezbolla Aggression : A total of 958 deaths since the beginning of the war....103630 Jtyc MCSE 0 08-07-2006 07:37 PM
Thunderbird Calendar with Exchange 2003 Calendar and Public FoldersCalendar jincmcse Firefox 1 09-03-2005 02:46 AM
Calendar control - adding a textbox on each day for data entry Keith-Earl ASP .Net Web Controls 3 10-26-2004 09:49 PM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM



Advertisments