Skip to content

Commit 8e362b3

Browse files
committed
Add experimental support for "now"
1 parent 7b65b05 commit 8e362b3

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ How to use
3535
e.g.
3636
+1d -12h 30m -1h30m -600s
3737

38+
now[<timediff>] now, or now plus <timediff>
39+
e.g.
40+
now now+1d now-1h30m
41+
3842
<timezone> in regexp: /^[-+][01][0-9][0-5][0-9]$/
3943

4044
<datetime> set this date time as commit time(s)

‎git-shift‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ usage: git shift [options] {[<time>][<timediff>][timezone]|<datetime>} <rev-list
5555
e.g.
5656
+1d -12h 30m -1h30m -600s
5757
58+
now[<timediff>] now, or now plus <timediff>
59+
e.g.
60+
now now+1d now-1h30m
61+
5862
<time> substitute this value for the time part(s) of
5963
current commit time(s)
6064
one of:
@@ -280,10 +284,13 @@ sub parse_timespec {
280284
my($otime, $otz) = @_;
281285
($ntime, defined($ntz) ? $ntz : $otz);
282286
};
283-
} elsif ($timespec =~ /\A(?=.)(([0-9]{2}):([0-9]{2})(?::([0-9]{2}))?)?($re_span)?($re_tz)?\z/o) {
284-
my($hhmmss, $hh, $mm, $ss, $span, $ntz) = ($1, $2, $3, $4, $5, $6);
287+
} elsif ($timespec =~ /\A(?=.)(([0-9]{2}):([0-9]{2})(?::([0-9]{2}))?)?(now|today)?($re_span)?($re_tz)?\z/o) {
288+
my($hhmmss, $hh, $mm, $ss, $now, $span, $ntz) = ($1, $2, $3, $4, $5, $6);
285289
return sub {
286290
my($otime, $otz) = @_;
291+
if (defined($now)) {
292+
$otime = time();
293+
}
287294
if (defined($span) && defined(my $seconds = parse_timediff($span))) {
288295
$otime += $seconds;
289296
}

0 commit comments

Comments
 (0)