
notvalid2 at sbcglobal
Aug 26, 2008, 5:21 PM
Post #5 of 20
(163 views)
Permalink
|
|
Re: Date Comparison and Manipulation Functions?
[In reply to]
|
|
zuul[at]ferg.org wrote: > check out Pyfdate: http://www.ferg.org/pyfdate > > from pyfdate import * > > t = Time().add(hours=14) > print "It is now", t.wdt > > datestring1 = "2005/10/05" #year,month,day > datestring2 = "2002/09/22" #year,month,day > datestring3 = "2007/11/11" #year,month,day > > year,month,day = numsplit(datestring1) # split into integers > t1 = Time(year,month,day) > for datestring in (datestring2,datestring1,datestring3): > year,month,day = numsplit(datestring) > t2 = Time(year,month,day) > > if t1 > t2: > print t1.isodate, "is later than ", t2.isodate > elif t1 == t2: > print t1.isodate, "is the same as ", t2.isodate > elif t1 < t2: > print t1.isodate, "is earlier than", t2.isodate > > print > > t1 = Time(2000,2,28) > print "The date after", t1.d, "is", t1.plus(day=1).d > t1 = Time(2001,2,28) > print "The date after", t1.d, "is", t1.plus(day=1).d > t1 = Time(2004,2,28) > print "The date after", t1.d, "is", t1.plus(day=1).d > > print > datestring1 = "2005/10/05 20:10:08" > datestring2 = "2005/10/05 20:10:06" > datestring3 = "2005/10/05 20:10:09" > > t1 = Time(*numsplit(datestring1)) > for datestring in (datestring2,datestring1,datestring3): > t2 = Time(*numsplit(datestring)) > > if t1 > t2: > print t1.d, t1.civiltime2, "is later than ", t2.d, t2.civiltime2 > elif t1 == t2: > print t1.d, t1.civiltime2, "is the same as ", t2.d, t2.civiltime2 > elif t1 < t2: > print t1.d, t1.civiltime2, "is earlier than", t2.d, t2.civiltime2 I'm using IDLE for Python 2.4, and put pfydate distribution in C:\Python24\Lib\site-packages\pfydate, as required by the <ttp://www.ferg.org/pyfdate/download.html> page. How to install pyfdate. Save pyfdate.py into your PythonNN/Lib/site-packages directory. I copied it into C:\Python24\Lib\site-packages\pfydate Execution in IDLE produced: --------------------------------- Traceback (most recent call last): File "C:\Sandia_Meteors\Improved_Sentinel\Sentinel_Playground\date_example.py", line 1, in ? from pyfdate import * ImportError: No module named pyfdate --------------------------------- Looking in the Path Browser, I don't see pyfdate. I see PIL package and scipy package. Comments? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet Web Page: <www.speckledwithstars.net/> -- http://mail.python.org/mailman/listinfo/python-list
|