Home | History | Annotate | Download | only in time

Lines Matching refs:time

9 	"time"
15 t0 := time.Now()
17 t1 := time.Now()
22 d, err := time.ParseDuration("1h15m30.918273645s")
27 round := []time.Duration{
28 time.Nanosecond,
29 time.Microsecond,
30 time.Millisecond,
31 time.Second,
32 2 * time.Second,
33 time.Minute,
34 10 * time.Minute,
35 time.Hour,
53 t1 := time.Date(2016, time.August, 15, 0, 0, 0, 0, time.UTC)
54 t2 := time.Date(2017, time.February, 16, 0, 0, 0, 0, time.UTC)
60 d, err := time.ParseDuration("1h15m30.918273645s")
65 trunc := []time.Duration{
66 time.Nanosecond,
67 time.Microsecond,
68 time.Millisecond,
69 time.Second,
70 2 * time.Second,
71 time.Minute,
72 10 * time.Minute,
73 time.Hour,
91 hours, _ := time.ParseDuration("10h")
92 complex, _ := time.ParseDuration("1h10m10s")
104 h, _ := time.ParseDuration("4h30m")
110 m, _ := time.ParseDuration("1h30m")
116 ns, _ := time.ParseDuration("1000ns")
122 m, _ := time.ParseDuration("1m30s")
135 case <-time.After(5 * time.Minute):
141 time.Sleep(100 * time.Millisecond)
147 c := time.Tick(1 * time.Minute)
154 _, month, day := time.Now().Date()
155 if month == time.November && day == 10 {
161 t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
167 ticker := time.NewTicker(time.Second)
171 time.Sleep(10 * time.Second)
180 fmt.Println("Current time: ", t)
186 // Parse a time value from a string in the standard Unix format.
187 t, err := time.Parse(time.UnixDate, "Sat Mar 7 11:06:39 PST 2015")
192 // time.Time's Stringer method is useful without any format.
196 fmt.Println("Unix format:", t.Format(time.UnixDate))
198 // The time zone attached to the time value affects its output.
199 fmt.Println("Same, in UTC:", t.UTC().Format(time.UnixDate))
205 // shows by example how the reference time should be represented.
206 // We stress that one must show how the reference time is formatted,
207 // not a time of the user's choosing. Thus each layout string is a
208 // representation of the time stamp,
248 // For instance, the second (05 in the reference time) in our value is 39,
254 do("Unix", time.UnixDate, "Sat Mar 7 11:06:39 PST 2015")
256 // The hour of the reference time is 15, or 3PM. The layout can express
258 // an AM time. We show both in one format string. Lower case too.
264 // Here we add a fractional second to our time value used above.
265 t, err = time.Parse(time.UnixDate, "Sat Mar 7 11:06:39.1234 PST 2015")
271 do("No fraction", time.UnixDate, "Sat Mar 7 11:06:39 PST 2015")
303 // See the example for Time.Format for a thorough description of how
304 // to define the layout string to parse a time.Time value; Parse and
307 // longForm shows by example how the reference time would be represented in
310 t, _ := time.Parse(longForm, "Feb 3, 2013 at 7:54pm (PST)")
313 // shortForm is another way the reference time would be represented
314 // in the desired layout; it has no time zone present.
315 // Note: without explicit zone, returns time in UTC.
317 t, _ = time.Parse(shortForm, "2013-Feb-03")
320 // Some valid layouts are invalid time values, due to format specifiers
323 // contains both Z and a time zone offset in order to handle both valid options:
326 t, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
328 t, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00")
330 _, err := time.Parse(time.RFC3339, time.RFC3339)
331 fmt.Println("error", err) // Returns an error as the layout is not a valid time value
338 // error parsing time "2006-01-02T15:04:05Z07:00": extra text: 07:00
342 loc, _ := time.LoadLocation("Europe/Berlin")
345 t, _ := time.ParseInLocation(longForm, "Jul 9, 2012 at 5:02am (CEST)", loc)
348 // Note: without explicit zone, returns time in given location.
350 t, _ = time.ParseInLocation(shortForm, "2012-Jul-09", loc)
360 fmt.Println(time.Unix(1e9, 0).UTC()) // 1e9 seconds
361 fmt.Println(time.Unix(0, 1e18).UTC()) // 1e18 nanoseconds
362 fmt.Println(time.Unix(2e9, -1e18).UTC()) // 2e9 seconds - 1e18 nanoseconds
364 t := time.Date(2001, time.September, 9, 1, 46, 40, 0, time.UTC)
377 t := time.Date(0, 0, 0, 12, 15, 30, 918273645, time.UTC)
378 round := []time.Duration{
379 time.Nanosecond,
380 time.Microsecond,
381 time.Millisecond,
382 time.Second,
383 2 * time.Second,
384 time.Minute,
385 10 * time.Minute,
386 time.Hour,
404 t, _ := time.Parse("2006 Jan 02 15:04:05", "2012 Dec 07 12:15:30.918273645")
405 trunc := []time.Duration{
406 time.Nanosecond,
407 time.Microsecond,
408 time.Millisecond,
409 time.Second,
410 2 * time.Second,
411 time.Minute,
412 10 * time.Minute,
419 midnight := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)
434 secondsEastOfUTC := int((8 * time.Hour).Seconds())
435 beijing := time.FixedZone("Beijing Time", secondsEastOfUTC)
439 // newYork, err := time.LoadLocation("America/New_York")
441 // Creating a time requires a location. Common locations are time.Local and time.UTC.
442 timeInUTC := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC)
443 sameTimeInBeijing := time.Date(2009, 1, 1, 20, 0, 0, 0, beijing)
445 // Although the UTC clock time is 1200 and the Beijing clock time is 2000, Beijing is
455 start := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC)
456 afterTenSeconds := start.Add(time.Second * 10)
457 afterTenMinutes := start.Add(time.Minute * 10)
458 afterTenHours := start.Add(time.Hour * 10)
459 afterTenDays := start.Add(time.Hour * 24 * 10)
462 fmt.Printf("start.Add(time.Second * 10) = %v\n", afterTenSeconds)
463 fmt.Printf("start.Add(time.Minute * 10) = %v\n", afterTenMinutes)
464 fmt.Printf("start.Add(time.Hour * 10) = %v\n", afterTenHours)
465 fmt.Printf("start.Add(time.Hour * 24 * 10) = %v\n", afterTenDays)
469 // start.Add(time.Second * 10) = 2009-01-01 12:00:10 +0000 UTC
470 // start.Add(time.Minute * 10) = 2009-01-01 12:10:00 +0000 UTC
471 // start.Add(time.Hour * 10) = 2009-01-01 22:00:00 +0000 UTC
472 // start.Add(time.Hour * 24 * 10) = 2009-01-11 12:00:00 +0000 UTC
476 start := time.Date(2009, 1, 1, 0, 0, 0, 0, time.UTC)
492 year2000 := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
493 year3000 := time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)
507 year2000 := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
508 year3000 := time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)
522 d := time.Date(2000, 2, 1, 12, 30, 0, 0, time.UTC)
536 d := time.Date(2000, 2, 1, 12, 30, 0, 0, time.UTC)
546 secondsEastOfUTC := int((8 * time.Hour).Seconds())
547 beijing := time.FixedZone("Beijing Time", secondsEastOfUTC)
550 // same instant but in different time zones.
551 d1 := time.Date(2000, 2, 1, 12, 30, 0, 0, time.UTC)
552 d2 := time.Date(2000, 2, 1, 20, 30, 0, 0, beijing)
566 timeWithNanoseconds := time.Date(2000, 2, 1, 12, 13, 14, 15, time.UTC)
569 timeWithoutNanoseconds := time.Date(2000, 2, 1, 12, 13, 14, 0, time.UTC)
581 start := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
582 end := time.Date(2000, 1, 1, 12, 0, 0, 0, time.UTC)
592 t := time.Date(2017, time.November, 4, 11, 0, 0, 0, time.UTC)
593 text := []byte("Time: ")
595 text = t.AppendFormat(text, time.Kitchen)
599 // Time: 11:00AM