<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## 語法 ### Func ``` func After(d Duration) <-chan Time func Sleep(d Duration) func Tick(d Duration) <-chan Time ``` ### Type ``` type Duration // 字符串轉時間 如 "2s" func ParseDuration(s string) (Duration, error) // Since返回從t到現在經過的時間,等價于time.Now().Sub(t) func Since(t Time) Duration func Until(t Time) Duration func (d Duration) Hours() float64 func (d Duration) Microseconds() int64 func (d Duration) Milliseconds() int64 func (d Duration) Minutes() float64 func (d Duration) Nanoseconds() int64 func (d Duration) Seconds() float64 func (d Duration) String() string func (d Duration) Round(m Duration) Duration // 取整 func (d Duration) Truncate(m Duration) Duration type Location func FixedZone(name string, offset int) *Location func LoadLocation(name string) (*Location, error) func LoadLocationFromTZData(name string, data []byte) (*Location, error) func (l *Location) String() string type Ticker func NewTicker(d Duration) *Ticker func (t *Ticker) Reset(d Duration) func (t *Ticker) Stop() type Time func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time func Now() Time func Parse(layout, value string) (Time, error) func ParseInLocation(layout, value string, loc *Location) (Time, error) func Unix(sec int64, nsec int64) Time func (t Time) Add(d Duration) Time func (t Time) AddDate(years int, months int, days int) Time func (t Time) AppendFormat(b []byte, layout string) []byte func (t Time) Sub(u Time) Duration func (t Time) After(u Time) bool func (t Time) Before(u Time) bool func (t Time) Clock() (hour, min, sec int) func (t Time) Date() (year int, month Month, day int) func (t Time) Year() int func (t Time) YearDay() int func (t Time) Minute() int func (t Time) Month() Month func (t Time) Day() int func (t Time) Hour() int func (t Time) Second() int func (t Time) Nanosecond() int func (t Time) Unix() int64 func (t Time) UnixNano() int64 func (t Time) Weekday() Weekday func (t Time) String() string func (t Time) Format(layout string) string func (t *Time) GobDecode(data []byte) error //對時間進行編解碼 func (t Time) GobEncode() ([]byte, error) func (t Time) MarshalBinary() ([]byte, error) func (t Time) MarshalJSON() ([]byte, error) func (t Time) MarshalText() ([]byte, error) func (t Time) In(loc *Location) Time func (t Time) IsZero() bool func (t Time) ISOWeek() (year, week int) func (t Time) Zone() (name string, offset int) func (t Time) Local() Time func (t Time) UTC() Time func (t Time) Location() *Location func (t Time) Equal(u Time) bool func (t Time) Round(d Duration) Time // 單位時間取整 func (t Time) Truncate(d Duration) Time func (t *Time) UnmarshalBinary(data []byte) error func (t *Time) UnmarshalJSON(data []byte) error func (t *Time) UnmarshalText(data []byte) error type Timer func AfterFunc(d Duration, f func()) *Timer func NewTimer(d Duration) *Timer func (t *Timer) Reset(d Duration) bool func (t *Timer) Stop() bool type Month func (m Month) String() string type ParseError func (e *ParseError) Error() string type Weekday func (d Weekday) String() string ``` ## 示例 ### ParseDuration 字符串轉時間 ``` // "300ms", "-1.5h" or "2h45m". // "ns", "us" (or "μs"), "ms", "s", "m", "h". duration, err := time.ParseDuration("2s") if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", duration.Seconds()) // 2 ``` ### time.Ticker 間隔執行功能 每秒輸出 hello word,可用于結構體的定時任務 ``` for { select { case <-time.Tick(time.Second): fmt.Printf("%+v\n", "hell world") } } ``` ### time.Round 時間取整 ``` t := time.Date(0, 0, 0, 12, 15, 30, 918273645, time.UTC) round := []time.Duration{ time.Nanosecond, time.Microsecond, time.Millisecond, time.Second, 2 * time.Second, time.Minute, 10 * time.Minute, time.Hour, } for _, d := range round { fmt.Printf("t.Round(%6s) = %s\n", d, t.Round(d).Format("15:04:05.999999999")) } // output t.Round( 1ns) = 12:15:30.918273645 t.Round( 1us) = 12:15:30.918274 t.Round( 1ms) = 12:15:30.918 t.Round( 1s) = 12:15:31 t.Round( 2s) = 12:15:30 t.Round( 1m0s) = 12:16:00 t.Round( 10m0s) = 12:20:00 t.Round(1h0m0s) = 12:00:00 ``` ### Truncate 時間取整,但不超出該時間 類似Round,但是返回的是最接近但早于t的時間點 ``` t, _ := time.Parse("2006 Jan 02 15:04:05", "2012 Dec 07 12:15:30.918273645") trunc := []time.Duration{ time.Nanosecond, time.Microsecond, time.Millisecond, time.Second, 2 * time.Second, time.Minute, 10 * time.Minute, time.Hour, } for _, d := range trunc { fmt.Printf("t.Truncate(%6s) = %s\n", d, t.Truncate(d).Format("15:04:05.999999999")) } // output t.Truncate( 1ns) = 12:15:30.918273645 t.Truncate( 1us) = 12:15:30.918273 t.Truncate( 1ms) = 12:15:30.918 t.Truncate( 1s) = 12:15:30 t.Truncate( 2s) = 12:15:30 t.Truncate( 1m0s) = 12:15:00 t.Truncate( 10m0s) = 12:10:00 t.Truncate(1h0m0s) = 12:00:00 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看