Changeset 38:fb741bfe9e1d in stamper for stamper


Ignore:
Timestamp:
Aug 12, 2014, 6:44:42 PM (10 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

The timeline feature accepts now date-based filters:

  • Show the timeline for the last week:

stamps -t 1w

  • Show the timeline for august, 2013:

stamps -t 2013-08-01--2013-09-01

And so on.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stamper/stamper.py

    r37 r38  
    237237        return details, totals, total_customer
    238238
    239     def timeline(self):
     239    def timeline(self, stamp_filter=None):
     240        filter_from, filter_to = self.validate_filter(stamp_filter)
    240241        for stamp in self.stamps:
    241242            customer = stamp['customer']
     243            start = datetime.strptime(stamp['start'], DATETIME_FORMAT)
     244            start_day = start.strftime('%Y-%m-%d')
     245            if filter_from and start < filter_from:
     246                # if there is a filter setting a starting date for the
     247                # report and the current stamp is from an earlier date, do
     248                # not add it to the totals
     249                continue
     250            if filter_to and start > filter_to:
     251                # similar for the end date
     252                continue
    242253            if not stamp['customer']:
    243254                print(stamp['start'] + ' start')
Note: See TracChangeset for help on using the changeset viewer.