Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(954)

Delta Between Two Patch Sets: src/pkg/time/format.go

Issue 6949058: code review 6949058: time: fix panic with time.Parse(time.StampNano, ... ) (Closed)
Left Patch Set: diff -r ee5afd4b14b7 https://code.google.com/p/go Created 11 years, 3 months ago
Right Patch Set: diff -r 111aa291b561 https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/time/time_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package time 5 package time
6 6
7 import "errors" 7 import "errors"
8 8
9 // These are predefined layouts for use in Time.Format. 9 // These are predefined layouts for use in Time.Format.
10 // The standard time used in the layouts is: 10 // The standard time used in the layouts is:
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if err != nil { 850 if err != nil {
851 break 851 break
852 } 852 }
853 // It's a valid format. 853 // It's a valid format.
854 zoneName = p 854 zoneName = p
855 855
856 case stdFracSecond0: 856 case stdFracSecond0:
857 // stdFracSecond0 requires the exact number of digits as specified in 857 // stdFracSecond0 requires the exact number of digits as specified in
858 // the layout. 858 // the layout.
859 ndigit := 1 + (std >> stdArgShift) 859 ndigit := 1 + (std >> stdArgShift)
860 » » » if len(value) >= ndigit { 860 » » » if len(value) < ndigit {
861 » » » » nsec, rangeErrString, err = parseNanoseconds(val ue, ndigit) 861 » » » » err = errBad
862 » » » » value = value[ndigit:] 862 » » » » break
863 » » » } 863 » » » }
864 » » » nsec, rangeErrString, err = parseNanoseconds(value, ndig it)
865 » » » value = value[ndigit:]
864 866
865 case stdFracSecond9: 867 case stdFracSecond9:
866 if len(value) < 2 || value[0] != '.' || value[1] < '0' | | '9' < value[1] { 868 if len(value) < 2 || value[0] != '.' || value[1] < '0' | | '9' < value[1] {
867 // Fractional second omitted. 869 // Fractional second omitted.
868 break 870 break
869 } 871 }
870 // Take any number of digits, even more than asked for, 872 // Take any number of digits, even more than asked for,
871 // because it is what the stdSecond case would do. 873 // because it is what the stdSecond case would do.
872 i := 0 874 i := 0
873 for i < 9 && i+1 < len(value) && '0' <= value[i+1] && va lue[i+1] <= '9' { 875 for i < 9 && i+1 < len(value) && '0' <= value[i+1] && va lue[i+1] <= '9' {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } 1072 }
1071 1073
1072 f += g * unit 1074 f += g * unit
1073 } 1075 }
1074 1076
1075 if neg { 1077 if neg {
1076 f = -f 1078 f = -f
1077 } 1079 }
1078 return Duration(f), nil 1080 return Duration(f), nil
1079 } 1081 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b