日期比较和操作功能? [英] Date Comparison and Manipulation Functions?
问题描述
是否有一些日期和时间比较功能可以比较,比如说
是否比2002年9月22日晚10/05/05? (或02/09/22格式,yy / mm / dd)
02/11/07与02/11/07相同吗?
是22:02:51之后的14:05:18? (24小时一天很好)
02/28/04之后的日期是02/29/04,或者是09/30/08之后的日期
10/01/08?
03/03/03 20:10:08 03/04/03 14:00:00之后怎么样?可能其他人
就足够了。
-
Wayne Watson(Watson Adventures,Prop。,Nevada City,CA)>
(121.015度W,39.262度N)GMT-8小时标准。时间)
Obz网站:39°15''7" N,121°2''32" W,2700英尺
网页:< www.speckledwithstars.net/>
Are there some date and time comparison functions that would compare, say,
Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd)
Is 02/11/07 the same as 02/11/07?
Is 14:05:18 after 22:02:51? (24 hour day is fine)
How about the date after 02/28/04 is 02/29/04, or the date after 09/30/08 is
10/01/08?
How about is 03/03/04 20:10:08 after 03/07/03 14:00:00? Probably the others
above will suffice.
--
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/>
推荐答案
" W。 eWatson" < no ******* @ sbcglobal.netwrites:
"W. eWatson" <no*******@sbcglobal.netwrites:
是否有一些可比较的日期和时间比较函数,比如
是否比2002年9月22日晚10/05/05? (或02/09/22格式,yy / mm / dd)
02/11/07与02/11/07相同吗?
是22:02:51之后的14:05:18? (24小时一天很好)
02/28/04之后的日期是02/29/04,或之后的日期
09 / 30/08是10/01/08?
03/03/03 20:10:08 03/04/03 14:00:00之后怎么样?可能上面的其他人就足够了。
Are there some date and time comparison functions that would compare, say,
Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd)
Is 02/11/07 the same as 02/11/07?
Is 14:05:18 after 22:02:51? (24 hour day is fine)
How about the date after 02/28/04 is 02/29/04, or the date after
09/30/08 is 10/01/08?
How about is 03/03/04 20:10:08 after 03/07/03 14:00:00? Probably the
others above will suffice.
http://docs.python。 org / lib / module-datetime.html
签出Pyfdate: http://www.ferg.org/pyfdate
来自pyfdate import的
*
t =时间()。添加(小时= 14)
打印现在是,t.wdt
datestring1 =" 2005 / 10月5日" #year,month,day
datestring2 =" 2002/09/22" #year,month,day
datestring3 =" 2007/11/11" #year,month,day
年,月,日= numsplit(datestring1)#拆分为整数
t1 =时间(年,月,日)
for datestring in(datestring2,datestring1,datestring3):
年,月,日= numsplit(datestring)
t2 =时间(年份,月,日)
如果t1 t2:
打印t1.isodate,晚于,t2.isodate
elif t1 == t2:
print t1.isodate,"",t2.isodate
elif t1< t2:
打印t1.isodate,早于,t2.isodate
打印
t1 =时间(2000,2,28)
打印 之后的日期,t1.d,是,t1.plus(day = 1).d
t1 =时间(2001,2,28)
print" t1.d之后的日期,是,t1.plus(day = 1).d
t1 =时间(2004,2,28)
print" t1.d之后的日期,是,t1.plus(day = 1)。打印
datestring1 =" 2005/10/05 20:10:08"
datestring2 =" 2005 / 10/05 20:10:06"
datestring3 =" 2005/10/05 20:10:09"
t1 =时间(* numsplit(datestring1))
for datestring in(datestring2,datestring1,datestring3):
t2 =时间(* numsplit(datestring))
如果t1 t2:
print t1.d,t1.civiltime2,晚于,t2.d,t2.civiltime2
elif t1 == t2:
print t1.d,t1.civiltime2,is t他和,t2.d,t2.civiltime2
elif t1< t2:
print t1.d,t1.civiltime2,早于,t2.d,t2.civiltime2
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
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
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
zu ** @ ferg.org 写道:
签出Pyfdate: http://www.ferg.org/pyfdate
来自pyfdate import *
t =时间()。添加(小时= 14)
打印现在是,t.wdt
datestring1 =" 2005/10/05" #year,month,day
datestring2 =" 2002/09/22" #year,month,day
datestring3 =" 2007/11/11" #year,month,day
年,月,日= numsplit(datestring1)#拆分为整数
t1 =时间(年,月,日)
for datestring in(datestring2,datestring1,datestring3):
年,月,日= numsplit(datestring)
t2 =时间(年份,月,日)
如果t1 t2:
打印t1.isodate,晚于,t2.isodate
elif t1 == t2:
print t1.isodate,"",t2.isodate
elif t1< t2:
打印t1.isodate,早于,t2.isodate
打印
t1 =时间(2000,2,28)
打印 之后的日期,t1.d,是,t1.plus(day = 1).d
t1 =时间(2001,2,28)
print" t1.d之后的日期,是,t1.plus(day = 1).d
t1 =时间(2004,2,28)
print" t1.d之后的日期,是,t1.plus(day = 1)。打印
datestring1 =" 2005/10/05 20:10:08"
datestring2 =" 2005 / 10/05 20:10:06"
datestring3 =" 2005/10/05 20:10:09"
t1 =时间(* numsplit(datestring1))
for datestring in(datestring2,datestring1,datestring3):
t2 =时间(* numsplit(datestring))
如果t1 t2:
print t1.d,t1.civiltime2,晚于,t2.d,t2.civiltime2
elif t1 == t2:
print t1.d,t1.civiltime2,"与,t2.d,t2.civiltime2
elif t1< t2:
print t1.d,t1.civiltime2,早于,t2.d,t2.civiltime2
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
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
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
It看起来不错。谢谢。
-
Wayne Watson(Watson Adventures,Prop。,Nevada City,CA)
(121.015°W,39.262°N)GMT-8 hr std。时间)
Obz网站:39°15''7" N,121°2''32" W,2700英尺
网页:< www.speckledwithstars.net/>
It looks good. Thanks.
--
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/>
这篇关于日期比较和操作功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!