コード例 #1
0
ファイル: Plan.py プロジェクト: xiaochang91/tapyr
def _date_time(Y, pat_match):
    if pat_match.date or pat_match.time:
        today = CAL.Date()
        if pat_match.weekday:
            wd = pat_match.weekday.lower()
            wk = int(pat_match.week or today.week)
            d = getattr(Y.weeks[wk - Y.weeks[0].number], wd).date
            if (pat_match.week is None) and d.rjd < today.rjd:
                d += 7
            day = d.day
            month = d.month
            year = d.year
        else:
            day = int(pat_match.day or today.day)
            month = int(pat_match.month or today.month)
            year = int(pat_match.year or today.year)
        time = pat_match.time or ""
        if time:
            if pat_match.hh_head:
                hh = int(pat_match.hh_head)
                mm = int(pat_match.mm_head or 0)
                time = "%2.2d:%2.2d" % (hh, mm)
                if pat_match.hh_tail:
                    hh = int(pat_match.hh_tail)
                    mm = int(pat_match.mm_tail or 0)
                    time = "%s-%2.2d:%2.2d" % (time, hh, mm)
        return day, month, year, time
    else:
        raise ValueError("`%s` must specify either date or time")
コード例 #2
0
 def _from_string_time (cls, s, ** kw) :
     future = kw.get ("future")
     date   = kw.get ("date")   or CAL.Date ()
     now    = kw.get ("time")   or CAL.Time ()
     time   = CAL.Time.from_string (s)
     if future and time < now :
         date += 1
     return cls.combine (date, time)
コード例 #3
0
 def as_plan (self) :
     self.sort_appointments ()
     d = self.date
     l = CAL.Date (d.year, 12, 31)
     holi = self.is_holiday or ""
     if holi :
         holi = "%26s" % ("=%s=" % (TFL.I18N.encode_o (holi), ),)
     return "\n".join \
         ( [ "# %s      %s#%2.2d, %s, day %d/-%d %s"
           % ( self
             , d.formatted ("%a")
             , d.week
             , d.formatted ("%d-%b-%Y")
             , d.rjd
             , l.rjd - d.rjd + 1
             , holi
             )
           ]
         + [str (a) for a in self.appointments or [""]]
         )
コード例 #4
0
 def _date(self, year):
     return CAL.Date(*easter_date(year))
コード例 #5
0
ファイル: Period.py プロジェクト: JPilarr/tapyr
 def start (self) :
     """Start date of period."""
     return CAL.Date (self.year, self.month, 1)
コード例 #6
0
ファイル: Period.py プロジェクト: JPilarr/tapyr
 def now (self) :
     return CAL.Date ()
コード例 #7
0
ファイル: Period.py プロジェクト: JPilarr/tapyr
 def start (self) :
     return CAL.Date (self.year, self.month, self.day)
コード例 #8
0
ファイル: Ordinal.py プロジェクト: JPilarr/tapyr
 def to_date(cls, mo):
     """Return date corresponding to month ordinal `mo`."""
     y, m = divmod(mo, 12)
     return CAL.Date(y, m or 12, 1)
コード例 #9
0
ファイル: Ordinal.py プロジェクト: JPilarr/tapyr
 def to_date(cls, yo):
     """Return date corresponding to year ordinal `yo`."""
     return CAL.Date(yo, 1, 1)
コード例 #10
0
      1 2016/01/01 Neujahr

    """
    import _CAL.Year
    with TFL.I18N.test_language (lang) :
        Y = CAL.Year (year)
        O = Y.head.ordinal - 1
        for ordinal, name in sorted (pyk.iteritems (holidays (year, country))) :
            print ("%3d %s %s" % (ordinal - O, Y.cal.day [ordinal], _T (name)))
# end def _show

def _main (cmd) :
    _show (cmd.year, cmd.country, cmd.language)
# end def _main

today    = CAL.Date ()
year     = today.year
_Command = TFL.CAO.Cmd \
    ( handler       = _main
    , args          =
        ( "year:I=%d?Year for which to show holidays" % (year, )
        ,
        )
    , opts          =
        ( "-country:S=AT?Country for which to show holidays"
        , "-language:S=de?Language to use for holiday names"
        )
    , max_args      = 1
    )

if __name__ != "__main__" :
コード例 #11
0
ファイル: Plan.py プロジェクト: xiaochang91/tapyr
        write_plan(Y, file_name, cmd.replace)


# end def _main

_Command = TFL.CAO.Cmd \
    ( handler     = _main
    , opts        =
        ( "add_appointment:B?Add appointments specified by arguments"
        , "diary:S=~/diary?Path for calendar file"
        , "filename:S=plan?Filename of plan for `year`"
        , "holidays_too:B?Add appointments to holidays, too"
        , "replace:B?Replace old calendar with new file"
        , "Show:B?Show days corresponding to arguments"
        , "sort:B?Sort calendar and write it back"
        , "year:I=%d?Year for which to process calendar" % (CAL.Date ().year, )
        )
    , 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
コード例 #12
0
ファイル: Holiday.py プロジェクト: JPilarr/tapyr
    279 2020-10-05 Implantação da República
    306 2020-11-01 Dia de Todos-os-Santos
    336 2020-12-01 Restauração da Independência
    343 2020-12-08 Imaculada Conceição
    360 2020-12-25 Natal

    >>> _show (2016, "ANY")
      1 2016-01-01 Neujahr

    """
    show_by_year(holidays, year, country, lang)


# end def _show

_year = CAL.Date().year


def show_by_event(rule, start, decades, country, language="de"):
    with TFL.I18N.test_language(language):
        head = TFL.rounded_down(start, 10)
        tail = head + 10 * decades
        fmt = "%8s"
        sep = " ".join(("=" * 4, *(("=" * 8, ) * 10)))

        def _gen_decade(d):
            for y in range(d, d + 10):
                evi = rule(y, country)
                yield fmt % ("" if evi is None else evi.event_abbr, )

        print(_T(rule.abbr), getattr(rule, "_start_date", ""))
コード例 #13
0
    , opts        =
        ( TFL.CAO.Opt.Date
            ( name        = "after"
            , description = "Only display entries after specified date"
            )
        , TFL.CAO.Opt.Date
            ( name        = "before"
            , description = "Only display entries before specified date"
            )
        , "-Config:P,?Config file(s)"
        , "-hpd:F=8?Hours per day"
        , "-ptf:F=1.0?Part time factor"
        , "-quiet:B?Show total only"
        , "-vacation:I=25?Days of vacation per year"
        , "-Weekly:B?Show weekly summary (default: monthly)"
        , "-year:I=%s?Show work time for year" % (CAL.Date ().year, )
        )
    , description = "Show work time specified by `zeiterfassung`."
    )

"""
$ for y in $(range 2001 2008)
do python /swing/python/Arbeitszeit.py -y $y -ptf 0.6 -hpd 5 ; done

y=2003; python /swing/python/Arbeitszeit.py -ptf 0.60 -hpd 5 -y $y \
  /swing/private/froelich/work/$y.dat -after 20030815

"""

if __name__ == "__main__":
    _Command ()
コード例 #14
0
 def as_date (self) :
     """Return `self` converted to pure `Date`."""
     return CAL.Date (date = self._body.date ())
コード例 #15
0
 def _date(self, year):
     return CAL.Date(year, self.month, self.day)
コード例 #16
0
ファイル: Ordinal.py プロジェクト: JPilarr/tapyr
 def to_date(cls, qo):
     """Return date corresponding to quarter ordinal `qo`."""
     y, q = divmod(qo, 4)
     return CAL.Date(y, ((q or 4) - 1) * 3 + 1, 1)
コード例 #17
0
                    ( "Nautic twilight starts %s, ends %s"
                    % (rts.nautic_twilight_start, rts.nautic_twilight_finis)
                    )
            if cmd.astro_twilight:
                print \
                    ( "Astro  twilight starts %s, ends %s"
                    % (rts.astro_twilight_start, rts.astro_twilight_finis)
                    )


# end def _main

_Command = TFL.CAO.Cmd \
    ( handler       = _main
    , args          =
        ( "date:S=%s" % CAL.Date ()
        ,
        )
    , opts          =
        ( "astro_twilight:B?Show astro twilight (-18 degrees below horizon)"
        , "civil_twilight:B?Show civil twilight (-6 degrees below horizon)"
        , "day_length:B?Show length of day in hours"
        , "latitude:F?Latitude (north is positive)"
        , "longitude:F?Longitude (negative is east of Greenwich)"
        , "-nautic_twilight:B"
            "?Show time of nautic twilight (sun -12 degrees below horizon)"
        , "-transit:B?Show transit height"
        , "-year:I?Show sunrise/transit/set data for whole year"
        , TFL.CAO.Opt.Location
            ( name        = "Location"
            , description = "Location of observer"
コード例 #18
0
ファイル: Anniversary.py プロジェクト: JPilarr/tapyr
 def __init__ (self, name, year, month, day, delta = None, ** kwds) :
     self._start_date    = CAL.Date (year, month, day)
     self.pop_to_self      (kwds, "abbr", prefix = "_")
     yf = lambda y : y >= year
     self.__super.__init__ \
         (name, month, day, delta = delta, y_filter = yf, ** kwds)