From c1ac7db2f3ab0d64e82c569a4282f05041bd0d53 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 23 Nov 2014 11:44:23 +0200 Subject: Implement --pretend-time --- jt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jt b/jt index dae3441..1b7a193 100755 --- a/jt +++ b/jt @@ -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) -- cgit v1.2.1