aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/time/format.go
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-22 17:43:43 -0300
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-22 17:43:43 -0300
commita926878ddbd5a98b272c22171ce58663fc04c3e0 (patch)
tree86af256e5d9a9c06263c00adc90e5fe348008c43 /libgo/go/time/format.go
parent542730f087133690b47e036dfd43eb0db8a650ce (diff)
parent07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff)
downloadgcc-devel/autopar_devel.zip
gcc-devel/autopar_devel.tar.gz
gcc-devel/autopar_devel.tar.bz2
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'libgo/go/time/format.go')
-rw-r--r--libgo/go/time/format.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/libgo/go/time/format.go b/libgo/go/time/format.go
index 9beb5d9..f11fb7e 100644
--- a/libgo/go/time/format.go
+++ b/libgo/go/time/format.go
@@ -67,7 +67,7 @@ import "errors"
// that insist on that format, and RFC3339 should be preferred for new protocols.
// RFC3339, RFC822, RFC822Z, RFC1123, and RFC1123Z are useful for formatting;
// when used with time.Parse they do not accept all the time formats
-// permitted by the RFCs.
+// permitted by the RFCs and they do accept time formats not formally defined.
// The RFC3339Nano format removes trailing zeros from the seconds field
// and thus may not sort correctly once formatted.
const (
@@ -856,7 +856,7 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
}
if std == 0 {
if len(value) != 0 {
- return Time{}, &ParseError{alayout, avalue, "", value, ": extra text: " + value}
+ return Time{}, &ParseError{alayout, avalue, "", value, ": extra text: " + quote(value)}
}
break
}
@@ -1112,7 +1112,7 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
return Time{}, &ParseError{alayout, avalue, "", value, ": day-of-year out of range"}
}
if m == 0 {
- m = yday/31 + 1
+ m = (yday-1)/31 + 1
if int(daysBefore[m]) < yday {
m++
}
@@ -1390,7 +1390,7 @@ func ParseDuration(s string) (Duration, error) {
return 0, nil
}
if s == "" {
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
for s != "" {
var (
@@ -1402,13 +1402,13 @@ func ParseDuration(s string) (Duration, error) {
// The next character must be [0-9.]
if !(s[0] == '.' || '0' <= s[0] && s[0] <= '9') {
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
// Consume [0-9]*
pl := len(s)
v, s, err = leadingInt(s)
if err != nil {
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
pre := pl != len(s) // whether we consumed anything before a period
@@ -1422,7 +1422,7 @@ func ParseDuration(s string) (Duration, error) {
}
if !pre && !post {
// no digits (e.g. ".s" or "-.s")
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
// Consume unit.
@@ -1434,17 +1434,17 @@ func ParseDuration(s string) (Duration, error) {
}
}
if i == 0 {
- return 0, errors.New("time: missing unit in duration " + orig)
+ return 0, errors.New("time: missing unit in duration " + quote(orig))
}
u := s[:i]
s = s[i:]
unit, ok := unitMap[u]
if !ok {
- return 0, errors.New("time: unknown unit " + u + " in duration " + orig)
+ return 0, errors.New("time: unknown unit " + quote(u) + " in duration " + quote(orig))
}
if v > (1<<63-1)/unit {
// overflow
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
v *= unit
if f > 0 {
@@ -1453,13 +1453,13 @@ func ParseDuration(s string) (Duration, error) {
v += int64(float64(f) * (float64(unit) / scale))
if v < 0 {
// overflow
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
}
d += v
if d < 0 {
// overflow
- return 0, errors.New("time: invalid duration " + orig)
+ return 0, errors.New("time: invalid duration " + quote(orig))
}
}