<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ~~~ package toolutilv3 import ( "fmt" "sort" "time" ) var ToolTime = toolTimeUtil{} type toolTimeUtil struct{} /* ParseInLocation 將指定格式的時間字符串解析為 time.Time 類型,使用本地時區 IsThisWeek 判斷給定的時間是否在本周內 GetNLastYears 獲取輸入時間往前N個年份 GetNLastQuarters 獲取輸入時間往前N個季度 GetNLastMonths 獲取輸入時間往前N個月 */ /* layout: 時間字符串格式 2006-01-02 15:04:05 value: 時間字符串 返回值: 解析后的 time.Time 對象 */ //ParseInLocation 將指定格式的時間字符串解析為 time.Time 類型,使用本地時區 func (t *toolTimeUtil) ParseInLocation(layout, value string) time.Time { // 使用 time.ParseInLocation 函數將字符串解析為 time.Time 類型 tt, _ := time.ParseInLocation(layout, value, time.Local) return tt } // IsThisWeek 判斷給定的時間是否在本周內 func (t *toolTimeUtil) IsThisWeek(tt time.Time) bool { // 獲取當前時間 now := time.Now() // 計算本周的開始時間 weekStart := now.AddDate(0, 0, -int(now.Weekday())) // 計算本周的結束時間 weekEnd := weekStart.AddDate(0, 0, 7) // 判斷時間是否在本周內,并返回結果 return !tt.Before(weekStart) && tt.Before(weekEnd) } /* isAsc 參數控制是否為升序排列。如果 isAsc 為 true,則按照升序排列;否則,按照降序排列。 */ // GetNLastYears 獲取輸入時間往前N個年份 func (t *toolTimeUtil) GetNLastYears(tt time.Time, n int, isAsc bool) []int { result := make([]int, n) for i := 0; i < n; i++ { result[i] = tt.Year() - i } if isAsc { sort.Ints(result) } return result } /* isAsc 參數控制是否為升序排列。如果 isAsc 為 true,則按照升序排列;否則,按照降序排列。 */ // GetNLastQuarters 獲取輸入時間往前N個季度 func (t *toolTimeUtil) GetNLastQuarters(tt time.Time, n int, isAsc bool) []string { result := make([]string, n) now := tt quarter := int(now.Month()-1)/3 + 1 // 獲取當前季度 lastQuarter := quarter // 計算上一季度 year := now.Year() lastYear := year for i := 0; i < n; i++ { if lastQuarter == 0 { // 上一季度是去年的 Q4 lastQuarter = 4 lastYear-- } quarterName := fmt.Sprintf("Q%d", lastQuarter) result[i] = fmt.Sprintf("%d-%s", lastYear, quarterName) lastQuarter-- } if isAsc { sort.Strings(result) } return result } /* isAsc 參數控制是否為升序排列。如果 isAsc 為 true,則按照升序排列;否則,按照降序排列。 */ // GetNLastMonths 獲取輸入時間往前N個月 func (t *toolTimeUtil) GetNLastMonths(tt time.Time, n int, isAsc bool) []string { result := make([]string, n) now := tt for i := 0; i < n; i++ { index := i if !isAsc { index = n - i - 1 } result[index] = now.AddDate(0, i-n+1, 0).Format("2006-01") } return result } ~~~
                  <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>

                              哎呀哎呀视频在线观看