elif isinstance (rhs, (datetime.date, datetime.datetime)) : return self.new_dtw (rhs - self._body) else : return self.dt_op (-rhs, operator.add) # end def __rsub__ def __str__ (self) : return self.as_string # end def __str__ def __sub__ (self, rhs) : return self.dt_op (rhs, operator.sub) # end def __sub__ # end class Relative_Delta class _Relative_Delta_Arg_ (TFL.CAO.Str) : """Argument or option with a (calendary) relative-delta value""" _real_name = "Relative_Delta" def cook (self, value, cao = None) : return Relative_Delta.from_string (value) # end def cook # end class _Delta_Arg_ if __name__ != "__main__" : CAL._Export ("*") ### __END__ CAL.Relative_Delta
# end def __lt__ def __sub__(self, rhs): return self.__class__(**{self.Class._kind: self._wrapped - rhs}) # end def __sub__ __str__ = property(lambda s: s._wrapped.__str__) # end class _Mutable_DTW_ @TFL._Add_Import_Callback("_TFL.json_dump") def _import_cb_json_dump(module): @module.default.add_type(_DTW_, _Mutable_DTW_) def json_encode_cal(o): try: encoder = o._body.isoformat except AttributeError: encoder = o.__str__ return encoder() # end def _import_cb_json_dump if __name__ != "__main__": CAL._Export("_DTW_", "_Mutable_DTW_") ### __END__ CAL._DTW_
) , description = """Manage appointments/activities in a yearly calendar. The arguments specify appointments. Examples of arguments: '7.1. +1w*52 14:30-15 =j SW-Jour-Fixe' '21.6. +1*8 =V Vacation' Argument syntax: <DD>.<MM>. +<delta><unit>*<how_often> <hh>:<mm>-<hh>:<mm> =<Prio> <Activity/Appointment> Date, repeat-info, time, and priority are all optional, but at least one field of date or time must be specified. Missing date fields are replaced by the current day/month. The delta-unit can be specified as `d` for days (default), `w` for weeks, or `m` for months. The priority is a single letter (upper or lowercase) or number. """ ) if __name__ != "__main__": CAL._Export("*") else: _Command() ### __END__ CAL.Plan
# 5-Jun-2004 (CT) Creation # 11-Aug-2007 (CT) U_Test ballast removed # ««revision-date»»··· #-- """A julian day number is a continuous count of days from the beginning of the year -4712. By (astronomical) tradition, the Julian Day begins at Greenwhich mean noon, that is, at 12h Universal Time. see Jean Meeus, Astronomical Algorithms, 1991, 1998 """ def JD (d, m, y) : """Returns Julian Day number for year `y`, month `m`, and day `d`.""" if m <= 2 : y -= 1 m += 12 if (y, m, d) >= (1582, 10, 15) : a = int (y / 100) b = 2 - a + int (a / 4) else : b = 0 jd = int (365.25 * (y + 4716)) + int (30.6001 * (m + 1)) + d + b - 1524.5 return jd # end def JD if __name__ != "__main__" : from _CAL import CAL CAL._Export ("JD") ### __END__ JD
_real_name = "Date_Delta" D_Type = Date_Delta # end class _Date_Delta_Arg_ class _Date_Time_Delta_Arg_(_Delta_Arg_): """Argument or option with a (calendary) datetime-delta value""" _real_name = "Date_Time_Delta" D_Type = Date_Time_Delta # end class _Date_Time_Delta_Arg_ class _Time_Delta_Arg_(_Delta_Arg_): """Argument or option with a (calendary) time-delta value""" _real_name = "Time_Delta" D_Type = Time_Delta # end class _Time_Delta_Arg_ if __name__ != "__main__": CAL._Export("*", "_Delta_Mixin_", "_Delta_", "Delta") ### __END__ CAL.Delta
if not sos.path.isdir (path) : sos.mkdir (path) if cmd.diary : create_diary (Y, path) if cmd.create : if cmd.Plan : write_year (Y.as_plan, pfil, cmd.force) if cmd.View : write_year (Y.as_cal, vfil, cmd.force) # end def _main _Command = TFL.CAO.Cmd \ ( handler = _main , opts = ( "create:B?Write files" , "diary:B?Create a diary file per day" , "force:B?Overwrite existing files if any" , "path:S=~/diary?Path for calendar files" , "Plan:S=plan?Filename of plan for `year`" , "View:S=view?Filename of view for `year`" , "year:I=%d?Year for which to process calendar" % (CAL.Date ().year, ) ) , max_args = 0 ) if __name__ != "__main__" : CAL._Export ("Year") else : _Command () ### __END__ CAL.Year
# Generic function returning a string usable for display in user interface # # Revision Dates # 6-Feb-2015 (CT) Creation # ««revision-date»»··· #-- from __future__ import division, print_function from __future__ import absolute_import, unicode_literals from _CAL import CAL import _CAL._DTW_ from _TFL.ui_display import * import datetime @ui_display.add_type(CAL._DTW_, datetime.date, datetime.time, datetime.timedelta) def _ui_display_date(obj): return pyk.text_type(obj) # end def _ui_display_date if __name__ != "__main__": CAL._Export("ui_display") ### __END__ CAL.ui_display
# Name # CAL.ui_display # # Purpose # Generic function returning a string usable for display in user interface # # Revision Dates # 6-Feb-2015 (CT) Creation # ««revision-date»»··· #-- from __future__ import division, print_function from __future__ import absolute_import, unicode_literals from _CAL import CAL import _CAL._DTW_ from _TFL.ui_display import * import datetime @ui_display.add_type (CAL._DTW_, datetime.date, datetime.time, datetime.timedelta) def _ui_display_date (obj) : return pyk.text_type (obj) # end def _ui_display_date if __name__ != "__main__" : CAL._Export ("ui_display") ### __END__ CAL.ui_display
# end class _Delta_Arg_ class _Date_Delta_Arg_ (_Delta_Arg_) : """Argument or option with a (calendary) date-delta value""" _real_name = "Date_Delta" D_Type = Date_Delta # end class _Date_Delta_Arg_ class _Date_Time_Delta_Arg_ (_Delta_Arg_) : """Argument or option with a (calendary) datetime-delta value""" _real_name = "Date_Time_Delta" D_Type = Date_Time_Delta # end class _Date_Time_Delta_Arg_ class _Time_Delta_Arg_ (_Delta_Arg_) : """Argument or option with a (calendary) time-delta value""" _real_name = "Time_Delta" D_Type = Time_Delta # end class _Time_Delta_Arg_ if __name__ != "__main__" : CAL._Export ("*", "_Delta_Mixin_", "_Delta_", "Delta") ### __END__ CAL.Delta