LEFT | RIGHT |
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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |