@@ -67,7 +67,9 @@ usage: git shift [options] {[<time>][<timediff>][timezone]|<datetime>} <rev-list
6767 <datetime> set this date time as commit time(s)
6868 one of:
6969 - ISO-8601 date time string
70+ - RFC 2822 date time format
7071 - date(1) format in C locale
72+ - Git's pretty format
7173 - number of seconds since the Unix epoch
7274
7375 <rev-list> speficy commits to modify which must be on the
@@ -325,21 +327,45 @@ sub parse_date {
325327 return ($time , $tzoffset ) unless $@ ;
326328 };
327329
328- if ($datetime =~ / \A ([A-Z][a-z]+\s +[A-Z][a-z]+\s +[0-9]{1,2}\s +[0-9]{2}:[0-9]{2}:[0-9]{2})\s +(?:UTC|GMT|([A-Z]+))\s +([0-9]+)\z / ) {
329- my ($date , $tzname , $year ) = ($1 , $2 , $3 );
330+ if ($datetime =~ qr {
331+ \A (?:
332+ # date(1) format in C locale
333+ (?<w>[A-Z][a-z]+) \s + (?<m>[A-Z][a-z]+) \s + (?<d>[0-9]{1,2}) \s +
334+ (?<T>[0-9]{2}:[0-9]{2}:[0-9]{2}) \s +
335+ (?:UTC|GMT|(?<z>[A-Z]+)) \s +
336+ (?<Y>[0-9]{4,})
337+ |
338+ # RFC 2822
339+ (?<w>[A-Z][a-z]+) , \s + (?<d>[0-9]{1,2}) \s + (?<m>[A-Z][a-z]+) \s +
340+ (?<Y>[0-9]{2,}) \s +
341+ (?<T>[0-9]{2}:[0-9]{2}:[0-9]{2}) \s +
342+ (?:UTC|GMT|(?<z>[A-Z]+|[-+][0-9]{2}:?[0-9]{2}))
343+ |
344+ # Git's pretty format
345+ (?<w>[A-Z][a-z]+) \s + (?<m>[A-Z][a-z]+) \s + (?<d>[0-9]{1,2}) \s +
346+ (?<T>[0-9]{2}:[0-9]{2}:[0-9]{2}) \s +
347+ (?<Y>[0-9]{4,}) \s +
348+ (?:UTC|GMT|(?<z>[-+][0-9]{4}))
349+ )\z
350+ } x ) {
351+ my ($year , $mon , $day , $wday , $time , $tzname ) = @+{qw( Y m d w T z) };
352+ warn (" $wday $mon $day $time $year $tzname " );
330353 eval {
331- my @localtzname = grep { !/\A(UTC|GMT|WILDABBR)\z/ } do {
332- POSIX::tzset();
333- POSIX::tzname();
334- };
335- $time = Time::Piece-> strptime(" $date $year " , ' %a %b %d %T %Y' );
354+ $time = Time::Piece-> strptime(" $wday $mon $day $time $year " , ' %a %b %d %T %Y' );
336355 if (defined ($tzname )) {
337- grep { $_ eq $tzname } @localtzname or die ' unrecognized time zone name' ;
338- $time = localtime (
339- timelocal($time -> sec, $time -> min, $time -> hour,
340- $time -> mday, $time -> _mon, $time -> year)
341- );
342- $tzoffset = $time -> tzoffset;
356+ if ($tzname =~ / \A [-+]/ ) {
357+ $tzname =~ s / :// ;
358+ $time = Time::Piece-> strptime($time -> strftime(' %Y-%m-%dT%T' ) . $tzname , ' %Y-%m-%dT%T%z' );
359+ $tzoffset = parse_tz($tzname );
360+ } elsif (grep { $_ eq $tzname } do { POSIX::tzset(); POSIX::tzname() }) {
361+ $time = localtime (
362+ timelocal($time -> sec, $time -> min, $time -> hour,
363+ $time -> mday, $time -> _mon, $time -> year)
364+ );
365+ $tzoffset = $time -> tzoffset;
366+ } else {
367+ die ' unrecognized time zone name' ;
368+ }
343369 } else {
344370 $tzoffset = 0;
345371 }
0 commit comments