LEFT | RIGHT |
(no file at all) | |
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // representations. For more information about the formats and the | 360 // representations. For more information about the formats and the |
361 // definition of the standard time, see the documentation for ANSIC. | 361 // definition of the standard time, see the documentation for ANSIC. |
362 func (t Time) Format(layout string) string { | 362 func (t Time) Format(layout string) string { |
363 var ( | 363 var ( |
364 year int = -1 | 364 year int = -1 |
365 month Month | 365 month Month |
366 day int | 366 day int |
367 hour int = -1 | 367 hour int = -1 |
368 min int | 368 min int |
369 sec int | 369 sec int |
370 » » b buffer | 370 » » b buffer = make([]byte, 0, len(layout)) |
371 ) | 371 ) |
372 // Each iteration generates one std value. | 372 // Each iteration generates one std value. |
373 for { | 373 for { |
374 prefix, std, suffix := nextStdChunk(layout) | 374 prefix, std, suffix := nextStdChunk(layout) |
375 b.WriteString(prefix) | 375 b.WriteString(prefix) |
376 if std == "" { | 376 if std == "" { |
377 break | 377 break |
378 } | 378 } |
379 | 379 |
380 // Compute year, month, day if needed. | 380 // Compute year, month, day if needed. |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 1029 } |
1030 | 1030 |
1031 f += g * unit | 1031 f += g * unit |
1032 } | 1032 } |
1033 | 1033 |
1034 if neg { | 1034 if neg { |
1035 f = -f | 1035 f = -f |
1036 } | 1036 } |
1037 return Duration(f), nil | 1037 return Duration(f), nil |
1038 } | 1038 } |
LEFT | RIGHT |