source: stamper/bin/stamp@ 30:b8003f616519

Last change on this file since 30:b8003f616519 was 27:a3e359b6eb37, checked in by Borja Lopez <borja@…>, 10 years ago

Use DATETIME_FORMAT instead of DATE_FORMAT in the stamp tool

  • Property exe set to *
File size: 902 bytes
RevLine 
[0]1#!/usr/bin/env python
2
3import sys
4from datetime import datetime
[27]5from stamper import DATETIME_FORMAT, Stamper
[0]6
7
8def usage(name):
9 msg = """
10 Usage:
11
12 To start tracking time: %(name)s
13
14 To record time for a given task: %(name)s customer action
15 """ % {'name': name}
16 print(msg)
17
18
19if __name__ == '__main__':
20
21 s = Stamper()
22 s.load_stamps()
23
24 if len(sys.argv) == 1:
25 # stamp!
[27]26 s.stamp(datetime.today().strftime(DATETIME_FORMAT),
27 None, None, None)
[0]28
29 elif len(sys.argv) == 3:
30 # record!
31 last_stamp = s.last_stamp()
32 current_start = last_stamp['end']
33 if not current_start:
34 current_start = last_stamp['start']
[27]35 s.stamp(current_start, datetime.today().strftime(DATETIME_FORMAT),
[0]36 sys.argv[1], sys.argv[2])
37
38 else:
39 usage(sys.argv[0])
40 sys.exit(1)
41
42 s.save_stamps()
Note: See TracBrowser for help on using the repository browser.