m .Ec@sdZddd!ZdkZdkZdkZdklZlZlZdklZl Z l Z l Z dk l Z dk lZd k lZlZlZlZd klZead Zyd klZWnd d fZnXeZdZdddddddddddddf ddddddddd d!d"d#d$f fZedd% \ZZZZZZ e!ed&Z"e!e"d'e"d(e"d)e"d*d+Z#eed(djoed)djped*djeZ$e#e$eed,ed-e d.d/Z%d0Z&ei'd1i(Z)d2fd3YZ*d4fd5YZ+d6Z,d7Z-d8Z.d9Z/d:Z0d;Z1d<Z2d=Z3d>Z4d?Z5d@Z6dAZ7dBZ8dCZ9dDZ:dEfdFYZ;dGfdHYZ<dIZ=dS(Js!Encapsulation of date/time valuess$Revision: 1.99 $i iN(stimesgmtimes localtime(sdaylightstimezonesaltzonesstrftime(sdatetime(s IDateTime(s DateTimeErrors SyntaxErrors DateErrors TimeError(s implementscCsHtdjo3y!dkl}|iatSWqDdSqDXntSdS(N(sgetConfigurationtus(tdefault_datefmttNonet App.configtgetConfigurationtdatetime_format(R((t0/data/zmath/zope/lib/python/DateTime/DateTime.pytgetDefaultDateFormats    (stznametUNKNOWNcCsttdS(Ni(troundt _system_time(((Rttime2siii;iZixiiiiii0iNi<i[iyiiiiii1iOiiimiidif693960.0f24.0f1440.0f86400.0iQl[Is[+-][0-9][0-9][0-9][0-9]t _timezonecBs2tZdZdZddZddZRS(NcCs4|\|_|_|_|_|_|_|_dS(N( tdatatselftnamettimectttypecttttransttindexttinfotaz(RR ((Rt__init__BscCsV|idjodSnx7t|iD]&}|i|ddjo|Sq(q(WdS(Nii(RRtrangeRtiR(RR((Rt default_indexFs cCs|pt}|idjo d}n||idjo,|i}|t|i d|f}nK||idjo}|idjo:t|i dt|i dt|i df}qt|i dt|i d|if}nxt |idD]}||i|djo|djo3t|i dt|i d|if}n?t|i |t|i |dt|i |df}PqqW|S(Niiii(iii( ttR RRtidxRRRtordRR(RRRR((RtindexLs$   :3 3> cCs[|i|d}|i|i|d}|i|d|i|d||id fS(Niiit(RRRRRRtzstfind(RRRR((Rtinfocs(t__name__t __module__RRRRR!(((RR As   t_cachecBstZddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddgZhdd<<dd=<dd<<dd<<dd<<dd<<ddU<ddU<dd:<dd<dd<dd<dd<dd<dd<dd<dd<dd <dd <dd <dd <dd3<dd <dd<dd'<dd<dd(<dd<dd(<dd(<dd'<dd-<dd.<dd<dd2<dd<dd<ddL<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<ddL<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<ddM<ddM<ddN<ddN<ddO<ddO<ddP<ddP<ddQ<ddQ<ddR<ddR<ddS<ddS<ddT<ddT<ddU<ddU<d dV<d dW<d dX<d dY<d dY<ddZ<ddZ<dd[<dd[<dd\<dd\<dd]<dd]<dd^<dd^<dd_<dd_<dd`<dd`<dda<dda<ddb<ddc<d dd<d!d<d"d<d#d<d$d<d%d<d&d<d'd<d(d<d)d<d*d<d+d-<d,d.<d-d<d.d!<d/d"<d0d#<d1d#<d2d#<d3d$<d4d%<d5d&<d6d'<d7d(<d8d)<d9d*<d:d+<d;d,<d<d-<d=d.<d>d/<d?d#<d@dL<dAd<dBd<dCd<dDd<dEd<dFd<dGd2<dHd<dId<dJd<dKd<dLd<dMdL<dNd<dOdL<dPdL<dQdL<dRdL<dSd<dTd<dUd<dVd<dWd<dXd<dYd<dZd<d[d<d\d<d]d<d^d<d_d<d`d<dad<dbdQThe time %f is beyond the range of this Python implementation.N( RRtt_intt isinstanceRt OverflowErrortgmtimet ValueErrort TimeErrortfloat(RR((Rt safegmtimes  cCsgy4t|}t|to tnt|SWn,ttfj otdt |nXdS(slocaltime with a safety zone.s>The time %f is beyond the range of this Python implementation.N( RRRRRRt localtimeRRR(RR((Rt safelocaltimes  cCsdt|ddS(sTakes an offset, such as from _tzoffset(), and returns an rfc822 compliant zone specification. Please note that the result of _tzoffset() is the negative of what time.localzone and time.altzone is.s %+03d%02di<N(tdivmodtseconds(R((Rt_tzoffset2rfc822zonescCsdt|ddS(sTakes an offset, such as from _tzoffset(), and returns an ISO 8601 compliant zone specification. Please note that the result of _tzoffset() is the negative of what time.localzone and time.altzone is.s %+03d:%02di<N(RR(R((Rt_tzoffset2iso8601zonesRcBs,tZdZeeeZdZeZe Z e Z e Z dZ dZ eidZeidZeideiZdZdZd d d d d d d d d d d d d f d d d d d d d d d d d d d f fZd d d ddddddddddf d d d ddddddddd d!f fZd"d#d$d%d&d'd(d)d*d+d,d-d.g Zd"d/d0d1d2d'd3d4d5d6d7d8d9g Zd"d:d;d<d=d'd(d)d>d?d@dAdBg ZhdCd<dDd<dEdF<dGdF<dHdI<dJdI<dKdL<dMdL<dNdO<dPdQ<dRdQ<dSdT<dUdT<dVdW<dXdW<dYdZ<d[dZ<d\dZ<d]d^<d_d^<d`da<dbda<dcdd<dedddZ?e?Z@dZAeAZBdZCeCZDdZEeEZFdZGeGZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSdZTdZUdZVdZWdZXdZYdZZdZ[dZ\dZ]dZ^dZ_dZ`dZadZbdZcdZddZedZfdZgdZhdZidZjdZkdZldZmdZndZodZpdZqdZrdZsdZtdZudZvdZwdZxdZydZzezZ{dZ|dZ}dZ~dZdZdZdZdZdZdZdZdZdZRS(sDateTime objects represent instants in time and provide interfaces for controlling its representation without affecting the absolute value of the object. DateTime objects may be created from a wide variety of string or numeric data, or may be computed from other DateTime objects. DateTimes support the ability to convert their representations to many major timezones, as well as the ablility to create a DateTime object in the context of a given timezone. DateTime objects provide partial numerical behavior: - Two date-time objects can be subtracted to obtain a time, in days between the two. - A date-time object and a positive or negative number may be added to obtain a new date-time object that is the given number of days later than the input date-time object. - A positive or negative number and a date-time object may be added to obtain a new date-time object that is the given number of days later than the input date-time object. - A positive or negative number may be subtracted from a date-time object to obtain a new date-time object that is the given number of days earlier than the input date-time object. DateTime objects may be converted to integer, long, or float numbers of days since January 1, 1901, using the standard int, long, and float functions (Compatibility Note: int, long and float return the number of days since 1901 in GMT rather than local machine timezone). DateTime objects also provide access to their value in a float format usable with the python time module, provided that the value of the object falls in the range of the epoch-based time module. A DateTime object should be considered immutable; all conversion and numeric operations return a new DateTime object rather than modify the current object.icOsVy|i||SWn;tttfj o ntd||fnXdS(sReturn a new date-time objectsUnable to parse %s, %sN(Rt _parse_argstargstkwt DateErrorRRt SyntaxError(RRR((RRsc Os |idt}d}}}t|}d}|djo(|\ }}}} }}}}}}n|djo+|\ }}}} }}}}}}}nx| p|o|ddjost}t|} |i| }|ti|}t|\}}| d \}}}} }}||}n|djoc|d}|djo t|nt|tov|i }t|} |i| }|ti|}t|\}}| d \}}}} }}||}qt|t!t"fo|i#|i$i%joyt|i$i&|i#}}|ti|}t|\}}t'||}t)||\}}}} }}qt|t!t"fo|i*dd jo9|d d jo(|i+|\}}}} }}}n(|i,||\}}}} }}}|i-|||pt.d |n|i/| |t0|pt1d |n|ti|}t2|||| ||}|oXy|i$i&|i#}Wqt3j o+t4|djot5d|qqXn|i6||}t7|||\}}}}q|}t|} |i| }|ti|}t|\}}| d \}}}} }}||}nu|djoWt|dt"o{|\}}|ti|}|i$i&|i#}t|\}}t'||}t)||\}}}} }}qt}t|} |i| }|\}}t9|}t:|ddt;|}|d} ti| } | | }t>| }t)||\}}}} }}t7|||\}}}}n|d \}}}d\} }}}t9|}|i-|||pt.d |fn|d}|o|d|d} }|om|d|d}}|oM|d|d}}|o-|d|d}}|o t5dqqqqn|i/| ||pt1d | n|d djo|ddjp|ddj} t2|||| ||}|ti|}|oXy|i$i&|i#}Wqt3j o+t4|djot5d|qqXn|i6||}t7|||\}}}}| djo| d|_@d|_An.| pd|_@| djodpd|_At0t:|||dd|_B}|iD||iE||iF||_G|_H|_I|iJ||iK||iL||_M|_N|_OtP|d}|djo d}nti||_Q||||_R|_S|_T| |||_U|_V|_W||||f\|_|_X|_Y|_Z|djot>ti|d}n||_[dS( s+Return a new date-time object A DateTime object always maintains its value as an absolute UTC time, and is represented in the context of some timezone based on the arguments used to create the object. A DateTime object's methods return values based on the timezone context. Note that in all cases the local machine timezone is used for representation if no timezone is specified. DateTimes may be created with from zero to seven arguments. - If the function is called with no arguments or with None, then the current date/time is returned, represented in the timezone of the local machine. - If the function is invoked with a single string argument which is a recognized timezone name, an object representing the current time is returned, represented in the specified timezone. - If the function is invoked with a single string argument representing a valid date/time, an object representing that date/time will be returned. As a general rule, any date-time representation that is recognized and unambigous to a resident of North America is acceptable.(The reason for this qualification is that in North America, a date like: 2/1/1994 is interpreted as February 1, 1994, while in some parts of the world, it is interpreted as January 2, 1994.) A date/time string consists of two components, a date component and an optional time component, separated by one or more spaces. If the time component is omited, 12:00am is assumed. Any recognized timezone name specified as the final element of the date/time string will be used for computing the date/time value. (If you create a DateTime with the string 'Mar 9, 1997 1:45pm US/Pacific', the value will essentially be the same as if you had captured time.time() at the specified date and time on a machine in that timezone)

            e=DateTime('US/Eastern')
            # returns current date/time, represented in US/Eastern.

            x=DateTime('1997/3/9 1:45pm')
            # returns specified time, represented in local machine zone.

            y=DateTime('Mar 9, 1997 13:45:00')
            # y is equal to x


            
New in Zope 2.4: The DateTime constructor automatically detects and handles ISO8601 compliant dates (YYYY-MM-DDThh:ss:mmTZD). See http://www.w3.org/TR/NOTE-datetime for full specs. The date component consists of year, month, and day values. The year value must be a one-, two-, or four-digit integer. If a one- or two-digit year is used, the year is assumed to be in the twentieth century. The month may an integer, from 1 to 12, a month name, or a month abreviation, where a period may optionally follow the abreviation. The day must be an integer from 1 to the number of days in the month. The year, month, and day values may be separated by periods, hyphens, forward, shashes, or spaces. Extra spaces are permitted around the delimiters. Year, month, and day values may be given in any order as long as it is possible to distinguish the components. If all three components are numbers that are less than 13, then a a month-day-year ordering is assumed. The time component consists of hour, minute, and second values separated by colons. The hour value must be an integer between 0 and 23 inclusively. The minute value must be an integer between 0 and 59 inclusively. The second value may be an integer value between 0 and 59.999 inclusively. The second value or both the minute and second values may be ommitted. The time may be followed by am or pm in upper or lower case, in which case a 12-hour clock is assumed. - If the DateTime function is invoked with a single Numeric argument, the number is assumed to be a floating point value such as that returned by time.time(). A DateTime object is returned that represents the gmt value of the time.time() float represented in the local machine's timezone. - If the DateTime function is invoked with a single argument that is a DateTime instane, a copy of the passed object will be created. - If the function is invoked with two numeric arguments, then the first is taken to be an integer year and the second argument is taken to be an offset in days from the beginning of the year, in the context of the local machine timezone. The date-time value returned is the given offset number of days from the beginning of the given year, represented in the timezone of the local machine. The offset may be positive or negative. Two-digit years are assumed to be in the twentieth century. - If the function is invoked with two arguments, the first a float representing a number of seconds past the epoch in gmt (such as those returned by time.time()) and the second a string naming a recognized timezone, a DateTime with a value of that gmt time will be returned, represented in the given timezone.
            import time
            t=time.time()

            now_east=DateTime(t,'US/Eastern')
            # Time t represented as US/Eastern

            now_west=DateTime(t,'US/Pacific')
            # Time t represented as US/Pacific

            # now_east == now_west
            # only their representations are different

            
- If the function is invoked with three or more numeric arguments, then the first is taken to be an integer year, the second is taken to be an integer month, and the third is taken to be an integer day. If the combination of values is not valid, then a DateError is raised. Two-digit years are assumed to be in the twentieth century. The fourth, fifth, and sixth arguments specify a time in hours, minutes, and seconds; hours and minutes should be positive integers and seconds is a positive floating point value, all of these default to zero if not given. An optional string may be given as the final argument to indicate timezone (the effect of this is as if you had taken the value of time.time() at that time on a machine in the specified timezone). New in Zope 2.7: A new keyword parameter "datefmt" can be passed to the constructor. If set to "international", the constructor is forced to treat ambigious dates as "days before month before year". This useful if you need to parse non-US dates in a reliable way In any case that a floating point number of seconds is given or derived, it's rounded to the nearest millisecond. If a string argument passed to the DateTime constructor cannot be parsed, it will raise DateTime.SyntaxError. Invalid date components will raise a DateError, while invalid time or timezone components will raise a DateTimeError. The module function Timezones() will return a list of the timezones recognized by the DateTime module. Recognition of timezone names is case-insensitive.tdatefmti i iiiRt iit-sInvalid date: %ssInvalid time: %ssUnknown time zone in date: %sif86400.0isToo many argumentsidisUnknown time zone: %si tpmtamlif60.0f59.999000000000002f1000.0N(iiii(\RtgetRRRRRRtlenRtact millisecsRRRRRRRR RtltRt localZoneRRRRtargRRRttimeTimetunicodetstrRRRRRRRR t_parse_iso8601t_parset _validDateRt _validTimeRRRRRRt_calcTimezoneNameRtjulRRRtx_floattx_floorRtleapt_pmhourt_pmt _dayoffsettdxt_monthst _months_at _months_pt_fmont_amont_pmont_dayst_days_at_days_pt_fdayt_adayt_pdayR t_nearsect_yeart_montht_dayt_hourt_minutet_secondRt_tt_tzt_millis(RRRRRRRRRR RR RRRRRRRRRRRRR((RRs  ( +         / %'('"   %       !"  2   '22  * s([0-9]+)s:([0-9]+\.[0-9]+)s ([a-zA-Z]+)s s-/.:,+iiiiii;iZixiiiiii0iNi<i[iyiiiiii1iORtJanuarytFebruarytMarchtApriltMaytJunetJulytAugustt SeptembertOctobertNovembertDecembertJantFebtMartAprtJuntJultAugtSeptOcttNovtDecsJan.sFeb.sMar.sApr.sAug.sSep.sOct.sNov.sDec.tjanuarytjantfebruaryitfebtmarchitmartaprilitaprtmayitjuneitjuntjulyiRtaugustitaugt septemberi tseptsepttoctoberi tocttnovemberi tnovtdecemberi tdectSundaytMondaytTuesdayt WednesdaytThursdaytFridaytSaturdaytSuntMontTuetWedtThutFritSatsSun.sMon.sTue.sWed.sThu.sFri.sSat.tsundaytsuntmondaytmonttuesdayttuesttuet wednesdaytwedtthursdaytthurstthurtthutfridaytfritsaturdaytsatcCs]tip tiSn|djott}n|d}|o tipti}|S(siReturns the time zone on the given date. The time zone can change according to daylight savings.iN( Rt_multipleZonest _localzone0tltmRRR Rt _localzone1R(RRtRR((RRs    c Cstip tiSnttid}||ttd|} yt | } Wnt |d\}} }}}} |ddd}t|| |||| }||ttd|} td| } t | } nX|i| }|S(Nf0.0lQiii(RRrRsRRRRRRRRRtRRRRRRRRtmaxRRR( RRRRRRRRRRRRRt((RRs  !c%Cs d}} } }|i}|i} |i }|i }|i}|i}|i}|ii}ddg}|i}|i}|d} | o*| i|jodi|d }nd} gg}}dt|}}x||jox-||jo|||jo|d}qW||jo)|||jo||}|d}nd}x-||jo|||jo|d}qaW|djo|d}n|}|i$||} | o9| i&d} |t| }|i(t)| qn| i$||} | o| i&d} t| }||}|djoA|o:|d jo-t|| d jod || f} qt+| }"|i(|"qn|i$||} | o| i&d| i&di}} |t| }||jo||d jo|d}n|i.| o1|| }"|djo |"}qt/|qn| |jo'|djo | }qt/|qn|i.| oqqnt/|qWd} |dd jou|d ddgjo_t|djoL|d} |d=|o|d} |d4qx|d}|d} |d4n(|o_t|djoH|ddjo|d} |d} n|d} |d} |d4qxnt|djo|ddjoK|d} |ddjo|d} |d}q&|d} |d}n|ddjo|d} |ddjo)|ddjo|d} |d}qm|ddjo)|ddjo|d} |d}qmn|ddjop|d} |ddjo|d} |d}qm|djo|d} |d}qm|d} |d}n4|ddjo"|d}|d} |d} n|d 4n| djo t2t3d \} }} nt4| } | djo t/|n| ddjo| ddjp| ddj}y1| p| |i6||jo t7|nWnt8j ot7|nXd}|o;|d}|o(|djo|djo|d}n|o$|djo|djo d}n|djo t:|n|t+|d}|d=|o|d}|d jo t:|n|t+|d }|d=|oM|d}|d jo t:|n||}|d=|o t/|qqqnt+t;i<|}||}!t?||!\}}}#| p1tC| || |||#}$|iE|$|!} n| || |||#| fS(NRRiRiiRis+-is%s%st.i<t:t/iii Riidiii(FRtmonthRRttmRt space_charstspacest int_patterntintpatt flt_patterntfltpatt name_patterntwordpatt delimiterst _monthmapt MonthNumberst_daymaptDayOfWeekNamesRRt ValidZonest TimeModifierststtstriptsplittspRtjointintstdelsRRtlRRtmatcht ts_resultstgroupRtappendRtlsRtvtothas_keyRtdayRRR RR t _month_lenRt IndexErrorttodRRRttod_intRRRRRRRR(%RRRRRRzRR}RRRRRRRR R{RRRRRRRRRRRRRRRRRRRR((RRsB                  :  %       :             " "             2  !!        cCsdS(N(N(R(R((Rt__getinitargs__bscCs|djp4|djp'|djp|djp |djodSn||i|ddjo|ddjp|ddj|jS(Nii iiiidi(RRRRR(RRRR((RResAcCsK|djo>|djo1|djo$|djo|djo |djS(Niii;i<(thRR(RRRR((RRiscCs+d|jot||Snt|dS(Nt%(RtstrftimeFormatterRtAttributeError(RR((Rt __getattr__ls cCs|iS(sReturn the date/time as a floating-point number in UTC, in the format used by the python time module. Note that it is possible to create date/time values with DateTime that have no meaningful value to the time module.N(RR"(R((RRrsc Cs}|i|ii|i}}|i}ymt |t ||d \}} } }}} |i} |i|| | ||| |||i|i| SWnt ||t |i|}|djo|Sn|i} | ti| } t|i|i|i|i|i| } | |}t"|| \}} } }}} |i|| | ||| |||i|i| SnXdS(siReturn a DateTime with the value as the current object, represented in the indicated timezone.iiN(#RR"RRRRRRRRRRRRRRRR!t __class__RR R#ttzdiffRRRRRRRRR Rtx_newR(RRRRRRRRRRRRRRR((RttoZonezs(  /    !cCs|itjS(s\Return true if this object represents a date/time later than the time of the callN(RR"R (R((RtisFuturescCs|itjS(s^Return true if this object represents a date/time earlier than the time of the callN(RR"R (R((RtisPastscCs0t}t|t|i|d|ijS(sReturn true if this object represents a date/time that falls within the current year, in the context of this object's timezone representationiN(R RRRRR#R(RR((Rt isCurrentYears cCsJt}t|t|i|}|d|ijo|d|ijS(sReturn true if this object represents a date/time that falls within the current month, in the context of this object's timezone representationiiN( R RRRRR#R`RR(RRR`((RtisCurrentMonths cCs^t}t|t|i|}|d|ijo%|d|ijo|d|i jS(sReturn true if this object represents a date/time that falls within the current day, in the context of this object's timezone representationiiiN( R RRRRR#R`RRR(RRR`((Rt isCurrentDays cCsrt}t|t|i|}|d|ijo9|d|ijo%|d|i jo|d|i jS(sReturn true if this object represents a date/time that falls within the current hour, in the context of this object's timezone representationiiiiN( R RRRRR#R`RRRR(RRR`((Rt isCurrentHours cCst}t|t|i|}|d|ijoM|d|ijo9|d|i jo%|d|i jo|d|i jS(sReturn true if this object represents a date/time that falls within the current minute, in the context of this object's timezone representationiiiiiN( R RRRRR#R`RRRRR (RRR`((RtisCurrentMinutes cCs+|i|i|i|iddd|iS(sReturn a new DateTime object that represents the earliest possible time (in whole seconds) that still falls within the current object's day, in the object's timezone contextiN(RRRRRR#(R((Rt earliestTimescCs+|i|i|i|iddd|iS(sReturn a new DateTime object that represents the latest possible time (in whole seconds) that still falls within the current object's day, in the object's timezone contextii;N(RRRRRR#(R((Rt latestTimescCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRt _upgrade_oldR"(RR((Rt greaterThans cCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than or equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRRR"(RR((RtgreaterThanEqualTos cCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRRR"(RR((RtequalTos cCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time not equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRRR"(RR((Rt notEqualTos cCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRRR"(RR((RtlessThan!s cCsby|i|ijSWn>tj o2y |iWqUtj o|iqUXnX|i|jS(sCompare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than or equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. N(RR$RRRR"(RR((RtlessThanEqualTo4s cCs9|iddjo%|iddjp|iddjS(scReturn true if the current year (in the context of the object's timezone) is a leap yeariiidiN(RR(R((Rt isLeapYearGscCsGt|it|i|id}t|tt|i ddS(s^Return the day of the year, in context of the timezone representation of the objectf86400.0iiN( RRRRR#R"RRRR(RR((Rt dayOfYearLs&cCs.|i|i|i|i|i|i|ifS(srReturn a tuple containing the calendar year, month, day, hour, minute second and timezone of the objectN(RRRRRR R!R#(R((RtpartsTscCs|iS(s7Return the timezone in which the object is represented.N(RR#(R((RRZscCst|i|iS(s4Return the timezone offset for the objects timezone.N(RRR#R"(R((Rttzoffset^scCs|iS(s&Return the calendar year of the objectN(RR(R((RRbscCs|iS(s,Return the month of the object as an integerN(RR(R((RRzfscCs|iS(sReturn the full month nameN(RR(R((RtMonthjscCs|iS(s!Return the abreviated month name.N(RR(R((RtaMonthnscCs|iS(sCompatibility: see aMonthN(RR(R((RR[rscCs|iS(s/Return the abreviated (with period) month name.N(RR(R((RtpMonthvscCs|iS(sCompatibility: see pMonthN(RR(R((RtMon_zscCs|iS(sReturn the integer dayN(RR(R((RR~scCs|iS(s+Return the full name of the day of the weekN(RR(R((RtDayscCs|iS(sCompatibility: see DayN(RR(R((Rt DayOfWeekscCs|iS(s1Return the abreviated name of the day of the weekN(RR(R((RtaDayscCs|iS(s?Return the abreviated (with period) name of the day of the weekN(RR(R((RtpDayscCs|iS(sCompatibility: see pDayN(RR(R((RtDay_scCs|iS(s5Return the integer day of the week, where sunday is 0N(RR (R((RtdowscCs |idS(s5Return the integer day of the week, where sunday is 1iN(RR (R((Rtdow_1scCs|iS(s3Return the 12-hour clock representation of the hourN(RR (R((Rth_12scCs|iS(s3Return the 24-hour clock representation of the hourN(RR(R((Rth_24scCs|iS(s/Return the appropriate time modifier (am or pm)N(RR (R((RtampmscCs|iS(s3Return the 24-hour clock representation of the hourN(RR(R((RthourscCs|iS(sReturn the minuteN(RR (R((RtminutescCs|iS(sReturn the secondN(RR!(R((RtsecondscCs/y |iSWntj o|iSnXdS(s.Return the millisecond since the epoch in GMT.N(RR$RR(R((RRs  cCs)tti|id}||_|S(s.Upgrades a previously pickled DateTime object.f1000.0N(RRRRR"RR$(RR((RRs c Cst|i|i|i|i|i|i}|i |d}t ||i t |i |i }||d}t|i|id}t}t|to|id}t}nt|i|i|i|i|it|i|i|}|ot|dp|S(Nif86400.0i@Bsutf-8(RRRRRRR R!RRtltzRR"R#RtzselfRRt microsecondstFalsetformat_is_unicodeRtformatRtencodetTruetdatetimetstrftimetds( RRRRRRRRR((RRs% cCsd|i|i|ifS(s&Return the date string for the object.s%s/%2.2d/%2.2dN(RRRR(R((RtDatescCsd|i|i|ifS(s;Return the time string for an object to the nearest second.s%2.2d:%2.2d:%2.2dN(RRR R(R((RtTimescCsd|i|ifS(s9Return the time string for an object not showing seconds.s %2.2d:%2.2dN(RRR (R((Rt TimeMinutesscCs d|i|i|i|ifS(s;Return the time string for an object to the nearest second.s%2.2d:%2.2d:%2.2d %sN(RR R RR (R((RtAMPMscCsd|i|i|ifS(s9Return the time string for an object not showing seconds.s%2.2d:%2.2d %sN(RR R R (R((Rt AMPMMinutesscCsd|i|i|ifS(s&Return the time string for the object.s%2.2d:%2.2d:%06.3fN(RRR R!(R((Rt PreciseTimescCs d|i|i|i|ifS(s&Return the time string for the object.s%2.2d:%2.2d:%06.3f %sN(RR R R!R (R((Rt PreciseAMPMscCst|idS(s(Return calendar year as a 2 digit stringiN(RRR(R((RtyyscCs d|iS(s Return month as a 2 digit strings%02dN(RR(R((RtmmscCs d|iS(sReturn day as a 2 digit strings%02dN(RR(R((RRsc CsPtt|i|i}d|i|i|i|i |i |i |i |fS(s!Return the date in RFC 822 formats$%s, %2.2d %s %d %2.2d:%2.2d:%2.2d %sN( RRRR#R"RRRRRRR R(RR((Rtrfc822scCs,d|i|i|i|i|i|ifS(s_Return a string representing the object's value in the format: March 1, 1997 1:45 pms%s %s, %4.4d %s:%2.2d %sN(RRRRR R R (R((RtfCommonscCs2d|i|i|i|i|i|i|ifS(sjReturn a string representing the object's value in the format: March 1, 1997 1:45 pm US/Easterns%s %s, %4.4d %d:%2.2d %s %sN(RRRRR R R R#(R((RtfCommonZscCs,d|i|i|i|i|i|ifS(s]Return a string representing the object's value in the format: Mar 1, 1997 1:45 pms%s %s, %4.4d %s:%2.2d %sN(RRRRR R R (R((RtaCommonscCs2d|i|i|i|i|i|i|ifS(shReturn a string representing the object's value in the format: Mar 1, 1997 1:45 pm US/Easterns%s %s, %4.4d %d:%2.2d %s %sN(RRRRR R R R#(R((RtaCommonZ$scCs,d|i|i|i|i|i|ifS(s^Return a string representing the object's value in the format: Mar. 1, 1997 1:45 pms%s %s, %4.4d %s:%2.2d %sN(RRRRR R R (R((RtpCommon+scCs2d|i|i|i|i|i|i|ifS(siReturn a string representing the object's value in the format: Mar. 1, 1997 1:45 pm US/Easterns%s %s, %4.4d %d:%2.2d %s %sN(RRRRR R R R#(R((RtpCommonZ2scCs,d|i|i|i|i|i|ifS(sReturn the object in ISO standard format. Note: this is *not* ISO 8601-format! See the ISO8601 and HTML4 methods below for ISO 8601-compliant output Dates are output as: YYYY-MM-DD HH:MM:SS s%.4d-%.2d-%.2d %.2d:%.2d:%.2dN(RRRRRR R!(R((RtISO:scCsJtt|i|i}d|i|i|i|i |i |i |fS(sReturn the object in ISO 8601-compatible format containing the date, time with seconds-precision and the time zone identifier - see http://www.w3.org/TR/NOTE-datetime Dates are output as: YYYY-MM-DDTHH:MM:SSTZD T is a literal character. TZD is Time Zone Designator, format +HH:MM or -HH:MM The HTML4 method below offers the same formatting, but converts to UTC before returning the value and sets the TZD "Z" s%%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d%sN( RRRR#R"RRRRRR R!(RR((RtISO8601Es cCs;|id}d|i|i|i|i|i|ifS(s*Return the object in the format used in the HTML4.0 specification, one of the standard forms in ISO8601. See http://www.w3.org/TR/NOTE-datetime Dates are output as: YYYY-MM-DDTHH:MM:SSZ T, Z are literal characters. The time is in UTC. R6s$%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2dZN( RRtnewdateRRRRR R!(RR((RtHTML4Wsc Cst|do tdnt|}|i}|i|d}|i |}|t i |}|t i |} t||} t| | \} }} }}} |i| || ||| |i||| S(swA DateTime may be added to a number and a number may be added to a DateTime; two DateTimes cannot be added.R"sCannot add two DateTimesf86400.0N(thasattrtotherRRRRR#RR"RRRRRRRRRRRRRRRRR(RRRRRRRRRRRRRRR((Rt__add__fs    !cCs4t|do|i|iSn|i| SdS(sEither a DateTime or a number may be subtracted from a DateTime, however, a DateTime may not be subtracted from a number.RN(RRRRR(RR((Rt__sub__vs cCsd|iit|fS(sNConvert a DateTime to a string that looks like a Python expression.s%s('%s')N(RRR"R(R((Rt__repr__scCs|i|i|i}}}|i|i|i |i f\}}}}||jo|jo djnod|||fSnR|t|jo!d|||||||fSnd|||||||fSdS(sConvert a DateTime to a string.is%4.4d/%2.2d/%2.2ds&%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %ss'%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%06.3f %sN(RRRRRRRRR R!R#RRRRR(RRRRRRRR((Rt__str__s**!cCshyt|i|iSWn>tj o2y |iWqXtj o|iqXXnXt|i|S(sCompare a DateTime with another DateTime object, or a float such as those returned by time.time(). NOTE: __cmp__ support is provided for backward compatibility only, and mixing DateTimes with ExtensionClasses could cause __cmp__ to break. You should use the methods lessThan, greaterThan, lessThanEqualTo, greaterThanEqualTo, equalTo and notEqualTo to avoid potential problems later!!N(tcmpRR$tobjRRR"(RR((Rt__cmp__s  cCs2t|idd|id|i|idS(s#Compute a hash value for a DateTimeidi iN(RRRRRR (R((Rt__hash__scCst|idS(s=Convert to an integer number of seconds since the epoch (gmt)iN(RRR(R((Rt__int__scCst|idS(s=Convert to a long-int number of seconds since the epoch (gmt)iN(RRR(R((Rt__long__scCs t|iS(sAConvert to floating-point number of seconds since the epoch (gmt)N(RRR"(R((Rt __float__scCs8y|i|SWn tj otd|nXdS(Ns+Not an ISO 8601 compliant date string: "%s"(Rt_DateTime__parse_iso8601RRR(RR((RRsc Cs"d} d} }d}}}} }ti d}ti d}ti d}|i |id}|dot|d} n|dot|d} n|dot|d}n|d} | o&|dp tn|i | }|dot|d}n|dot|d}n|dot|d}n|do|t|d}n|d } | o| id o| d} n| oH|i | }t|d} t|d}|d o tqqn| | ||||d | |ffS(s" parse an ISO 8601 compliant date iis*([0-9]{4})(-([0-9][0-9]))?(-([0-9][0-9]))?s;T([0-9]{2})(:([0-9][0-9]))?(:([0-9][0-9]))?(\.[0-9]{1,20})?s ([+-][0-9][0-9])(:?([0-9][0-9]))iiiitZis GMT%+03d%02dN(RRzRRRRthour_offtmin_offtretcompiletdateregttimeregtzoneregRRRtfieldsRRRRRt startswith(RRRRRRRRRRzRRRRRR((Rt__parse_iso8601sJ             cCsrd|id}|id|}|id|d}|id|ddd||d |d |d d S(st Return the Julian day according to http://www.tondering.dk/claus/cal/node3.html#sec-calcjd ii iiiiiimiidii-}N(RRRRRRR(RRRR((Rt JulianDays cCsR|i}|d|dddd}|d}||d|}|ddS( s Return the week number according to ISO see http://www.tondering.dk/claus/cal/node6.html#SECTION00670000000000000000 i{ii:iiiimiN(RRtJtd4tLtd1(RR RR R ((Rtweeks   cCs1|id|i|i|iddS(s* Encode value for XML-RPC ss N(touttwriteRR(RR ((RRs (R"R#t__doc__t implementst IDateTimeRt __roles__t*__allow_access_to_unprotected_subobjects__RRRRRRRRR~RtIRR|RRt _until_monthRRRRRRRRRRsRuRrRR t_isDSTRR$RRRRRRRRRRRRRRRRRRRRRt__gt__Rt__ge__Rt__eq__Rt__ne__Rt__lt__Rt__le__RRRRRRRzRRR[RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRt__radd__RRRRRRRRRRRR R(((RRs (  UZZ---                                                                                  / RcBstZdZdZRS(NcCs||_||_dS(N(tdtRt_dtRt_f(RRR((RRs cCs|ii|iS(N(RRRR (R((Rt__call__s(R"R#RR!(((RRs cCstiS(s,Return the list of recognized timezone namesN(R$R(((Rt Timezoness(>Rt __version__RRRR RRRRRRRt interfacesRRRRRtzope.interfaceRRRRRR R{RRRRRRRRtto_yeartto_monthRRRRRR R$RRRRRRRRRRRRRRRRRR"(6RRRRRRRRRRR$RRRR RRRRRRRRR{R#RRRRR RRRRRR&R'RRRRRRRRRR"RRRRR RR((Rt? sb      Z",:**          [