• Alberto Donizetti's avatar
    time: allow +00 as numeric timezone name and GMT offset · 38143bad
    Alberto Donizetti authored
    A timezone with a zero offset from UTC and without a three-letter
    abbreviation will have a numeric name in timestamps: "+00".
    
    There are currently two of them:
    
      $ zdump Atlantic/Azores America/Scoresbysund
      Atlantic/Azores       Wed Aug 22 09:01:05 2018 +00
      America/Scoresbysund  Wed Aug 22 09:01:05 2018 +00
    
    These two timestamp are rejected by Parse, since it doesn't allow for
    zero offsets:
    
      parsing time "Wed Aug 22 09:01:05 2018 +00": extra text: +00
    
    This change modifies Parse to accept a +00 offset in numeric timezone
    names.
    
    As side effect of this change, Parse also now accepts "GMT+00". It was
    explicitely disallowed (with a unit test ensuring it got rejected),
    but the restriction seems incorrect.
    
    DATE(1), for example, allows it:
    
      $ date --debug --date="2009-01-02 03:04:05 GMT+00"
    
      date: parsed date part: (Y-M-D) 2009-01-02
      date: parsed time part: 03:04:05
      date: parsed zone part: UTC+00
      date: input timezone: parsed date/time string (+00)
      date: using specified time as starting value: '03:04:05'
      date: starting date/time: '(Y-M-D) 2009-01-02 03:04:05 TZ=+00'
      date: '(Y-M-D) 2009-01-02 03:04:05 TZ=+00' = 1230865445 epoch-seconds
      date: timezone: system default
      date: final: 1230865445.000000000 (epoch-seconds)
      date: final: (Y-M-D) 2009-01-02 03:04:05 (UTC)
      date: final: (Y-M-D) 2009-01-02 04:04:05 (UTC+01)
      Fri  2 Jan 04:04:05 CET 2009
    
    This fixes 2 of 17 time.Parse() failures listed in Issue #26032.
    
    Updates #26032
    
    Change-Id: I01cd067044371322b7bb1dae452fb3c758ed3cc2
    Reviewed-on: https://go-review.googlesource.com/130696
    Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    38143bad
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...