diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-11-23 11:44:23 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-11-23 11:44:23 +0200 |
commit | c1ac7db2f3ab0d64e82c569a4282f05041bd0d53 (patch) | |
tree | 4aa46d081af6c1fa44adbdddd4eb1e7632b1aebe | |
parent | 8c308d8670c1094119495774d7e29de4e2edf08c (diff) | |
download | jt-c1ac7db2f3ab0d64e82c569a4282f05041bd0d53.tar.gz |
Implement --pretend-time
-rwxr-xr-x | jt | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -121,7 +121,7 @@ class NewCommand(Command): values = { 'title': args[0], - 'date': time.strftime('%Y-%m-%d %H:%M'), + 'date': time.strftime('%Y-%m-%d %H:%M', self._app.now_tuple), 'topiclink': self._get_topic_link(topic), } @@ -209,7 +209,7 @@ class FinishCommand(Command): self._push_git() def _published_dir(self): - subdir = time.strftime('notes/%Y/%m/%d') + subdir = time.strftime('notes/%Y/%m/%d', self._app.now_tuple) return os.path.join(self._app.settings['source'], subdir) def _summarise_title(self, title): @@ -232,7 +232,7 @@ class FinishCommand(Command): def _commit_to_git(self, pathnames): cliapp.runcmd( - ['git', 'add'] + pathname, + ['git', 'add'] + pathnames, cwd=self._app.settings['source']) cliapp.runcmd( @@ -348,6 +348,14 @@ class JournalTool(cliapp.Application): 'pretend that the time is NOW (form: YYYY-MM-DD HH:MM:DD form)', metavar='NOW') + def process_args(self, args): + if self.settings['pretend-time']: + self.now_tuple = time.strptime( + self.settings['pretend-time'], '%Y-%m-%d %H:%M:%S') + else: + self.now_tuple = time.localtime() + cliapp.Application.process_args(self, args) + def cmd_new(self, args): '''Create a new journal entry draft.''' NewCommand(self).run(args) |