當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Time.Minute方法代碼示例

本文整理匯總了Golang中Time.Time.Minute方法的典型用法代碼示例。如果您正苦於以下問題:Golang Time.Minute方法的具體用法?Golang Time.Minute怎麽用?Golang Time.Minute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Time.Time的用法示例。


在下文中一共展示了Time.Minute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: EndOf

// EndOf returns the end of the passed unit for the given time.
func EndOf(t time.Time, unit UnitOfTime) time.Time {
	// Retrieve the individual parts of the given time.
	year := t.Year()
	month := t.Month()
	day := t.Day()
	hour := t.Hour()
	minute := t.Minute()
	second := t.Second()
	loc := t.Location()
	// Build new time.
	switch unit {
	case Second:
		return time.Date(year, month, day, hour, minute, second, 999999999, loc)
	case Minute:
		return time.Date(year, month, day, hour, minute, 59, 999999999, loc)
	case Hour:
		return time.Date(year, month, day, hour, 59, 59, 999999999, loc)
	case Day:
		return time.Date(year, month, day, 23, 59, 59, 999999999, loc)
	case Month:
		// Catching leap years makes the month a bit more complex.
		_, nextMonth, _ := t.AddDate(0, 1, 0).Date()
		return time.Date(year, nextMonth, 1, 23, 59, 59, 999999999, loc).AddDate(0, 0, -1)
	case Year:
		return time.Date(year, time.December, 31, 23, 59, 59, 999999999, loc)
	default:
		return t
	}
}
開發者ID:kung-foo,項目名稱:golib,代碼行數:30,代碼來源:timex.go

示例2: FmtTimeMedium

// FmtTimeMedium returns the medium time representation of 't' for 'ar_SA'
func (ar *ar_SA) FmtTimeMedium(t time.Time) string {

	b := make([]byte, 0, 32)

	h := t.Hour()

	if h > 12 {
		h -= 12
	}

	b = strconv.AppendInt(b, int64(h), 10)
	b = append(b, ar.timeSeparator...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, ar.timeSeparator...)

	if t.Second() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Second()), 10)
	b = append(b, []byte{0x20}...)

	if t.Hour() < 12 {
		b = append(b, ar.periodsAbbreviated[0]...)
	} else {
		b = append(b, ar.periodsAbbreviated[1]...)
	}

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:36,代碼來源:ar_SA.go

示例3: FmtTimeLong

// FmtTimeLong returns the long time representation of 't' for 'en_SC'
func (en *en_SC) FmtTimeLong(t time.Time) string {

	b := make([]byte, 0, 32)

	if t.Hour() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Hour()), 10)
	b = append(b, en.timeSeparator...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, en.timeSeparator...)

	if t.Second() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Second()), 10)
	b = append(b, []byte{0x20}...)

	tz, _ := t.Zone()
	b = append(b, tz...)

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:31,代碼來源:en_SC.go

示例4: FmtTimeLong

// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl_RS'
func (sr *sr_Cyrl_RS) FmtTimeLong(t time.Time) string {

	b := make([]byte, 0, 32)

	if t.Hour() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Hour()), 10)
	b = append(b, []byte{0x2e}...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, []byte{0x2e}...)

	if t.Second() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Second()), 10)
	b = append(b, []byte{0x20}...)

	tz, _ := t.Zone()
	b = append(b, tz...)

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:31,代碼來源:sr_Cyrl_RS.go

示例5: FmtTimeShort

// FmtTimeShort returns the short time representation of 't' for 'ta_MY'
func (ta *ta_MY) FmtTimeShort(t time.Time) string {

	b := make([]byte, 0, 32)

	if t.Hour() < 12 {
		b = append(b, ta.periodsAbbreviated[0]...)
	} else {
		b = append(b, ta.periodsAbbreviated[1]...)
	}

	b = append(b, []byte{0x20}...)

	h := t.Hour()

	if h > 12 {
		h -= 12
	}

	b = strconv.AppendInt(b, int64(h), 10)
	b = append(b, ta.timeSeparator...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:30,代碼來源:ta_MY.go

示例6: FmtTimeShort

// FmtTimeShort returns the short time representation of 't' for 'as_IN'
func (as *as_IN) FmtTimeShort(t time.Time) string {

	b := make([]byte, 0, 32)

	h := t.Hour()

	if h > 12 {
		h -= 12
	}

	b = strconv.AppendInt(b, int64(h), 10)
	b = append(b, []byte{0x2e}...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, []byte{0x2e, 0x20}...)

	if t.Hour() < 12 {
		b = append(b, as.periodsAbbreviated[0]...)
	} else {
		b = append(b, as.periodsAbbreviated[1]...)
	}

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:29,代碼來源:as_IN.go

示例7: FmtTimeShort

// FmtTimeShort returns the short time representation of 't' for 'dz_BT'
func (dz *dz_BT) FmtTimeShort(t time.Time) string {

	b := make([]byte, 0, 32)

	b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...)

	h := t.Hour()

	if h > 12 {
		h -= 12
	}

	b = strconv.AppendInt(b, int64(h), 10)
	b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, []byte{0x20}...)

	if t.Hour() < 12 {
		b = append(b, dz.periodsAbbreviated[0]...)
	} else {
		b = append(b, dz.periodsAbbreviated[1]...)
	}

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:31,代碼來源:dz_BT.go

示例8: EasyDate

func EasyDate(d time.Time) string {
	twZone, err := time.LoadLocation("Asia/Taipei")
	if err != nil {
		log.Print(err.Error())
		return ""
	}

	now := time.Now().In(twZone)
	today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, twZone)
	this_year := time.Date(now.Year(), time.January, 1, 0, 0, 0, 0, twZone)
	yesterday := today.Add(-24 * time.Hour)
	twoDaysBefore := yesterday.Add(-24 * time.Hour)

	str := fmt.Sprintf("%02d:%02d:%02d", d.Hour(), d.Minute(), d.Second())
	if d.After(yesterday) && d.Before(today) {
		str = "昨天 " + str
	} else if d.After(twoDaysBefore) && d.Before(yesterday) {
		str = "前天 " + str
	} else if d.After(this_year) && d.Before(twoDaysBefore) {
		str = fmt.Sprintf("%d 月 %d 日 ", d.Month(), d.Day()) + str
	} else if d.Before(this_year) {
		str = fmt.Sprintf("%02d-%02d-%02d ", d.Year()-1911, d.Month(), d.Day()) + str
	}

	return str
}
開發者ID:a2n,項目名稱:alu,代碼行數:26,代碼來源:alu.go

示例9: TheHour

func (f Format) TheHour(n int, t time.Time) (b []byte) {
	b = make([]byte, 0, 64)
	for _, f := range bytes.Fields(f) {
		switch f[0] {
		case '#':
			b = append(b, Numbers[n]...)
		case 'h':
			b = append(b, []byte(`THE HOUR`)...)
		case 'm':
			m := t.Minute()
			b = append(b, Numbers[m]...)
			if len(f) == 2 && f[1] == '_' {
				b = append(b, Sminute...)
				if m != 1 {
					b = append(b, 'S')
				}
			}
		case 's':
			s := t.Second()
			b = append(b, Numbers[s]...)
			if len(f) == 2 && f[1] == '_' {
				b = append(b, Ssecond...)
				if s != 1 {
					b = append(b, 'S')
				}
			}
		default:
			b = append(b, f...)
		}
		b = append(b, ' ')
	}
	return b[:len(b)-1]
}
開發者ID:jbaikge,項目名稱:ingress-measurement,代碼行數:33,代碼來源:format.go

示例10: FmtTimeFull

// FmtTimeFull returns the full time representation of 't' for 'th_TH'
func (th *th_TH) FmtTimeFull(t time.Time) string {

	b := make([]byte, 0, 32)

	b = strconv.AppendInt(b, int64(t.Hour()), 10)
	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)

	if t.Second() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Second()), 10)
	b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...)

	tz, _ := t.Zone()

	if btz, ok := th.timezones[tz]; ok {
		b = append(b, btz...)
	} else {
		b = append(b, tz...)
	}

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:32,代碼來源:th_TH.go

示例11: main

func main() {
	p := fmt.Println
	var t time.Time = time.Now()
	fmt.Println(t)
	fmt.Println(t.Format(time.RFC3339))
	fmt.Println(t.Format(time.RFC3339Nano))

	t1, e := time.Parse(
		time.RFC3339,
		"2012-11-01T22:08:41-04:00")
	p(t1)

	p(t.Format("3:04PM"))
	p(t.Format("Mon Jan _2 15:04:05 2006"))
	p(t.Format("2006-01-02T15:04:05.999999-07:00"))
	form := "3 04 PM"
	t2, e := time.Parse(form, "8 41 PM")
	p(t2)
	fmt.Printf("%d - %02d - %02d T %02d : %02d : %02d . %d -00:00\n",
		t.Year(), t.Month(), t.Day(),
		t.Hour(), t.Minute(), t.Second(), t.Nanosecond())
	ansic := "Mon Jan _2 15:04:05 2006"
	_, e = time.Parse(ansic, "8:41PM")
	p(e)
}
開發者ID:trsathya,項目名稱:go,代碼行數:25,代碼來源:timeFormatting.go

示例12: timeToSystemTime

func (de *DateEdit) timeToSystemTime(t time.Time) *win.SYSTEMTIME {
	if t.Year() < 1601 {
		if de.hasStyleBits(win.DTS_SHOWNONE) {
			return nil
		} else {
			return &win.SYSTEMTIME{
				WYear:  uint16(1601),
				WMonth: uint16(1),
				WDay:   uint16(1),
			}
		}
	}

	st := &win.SYSTEMTIME{
		WYear:  uint16(t.Year()),
		WMonth: uint16(t.Month()),
		WDay:   uint16(t.Day()),
	}

	if de.timeOfDayDisplayed() {
		st.WHour = uint16(t.Hour())
		st.WMinute = uint16(t.Minute())
		st.WSecond = uint16(t.Second())
	}

	return st
}
開發者ID:wangch,項目名稱:walk,代碼行數:27,代碼來源:dateedit.go

示例13: IsDue

// IsDue check if current moment is match fo expression
func (expr *Expr) IsDue(args ...time.Time) bool {
	var t time.Time

	if len(args) >= 1 {
		t = args[0]
	} else {
		t = time.Now()
	}

	if expr.minutes.index[uint8(t.Minute())] == false {
		return false
	}

	if expr.hours.index[uint8(t.Hour())] == false {
		return false
	}

	if expr.doms.index[uint8(t.Day())] == false {
		return false
	}

	if expr.months.index[uint8(t.Month())] == false {
		return false
	}

	if expr.dows.index[uint8(t.Weekday())] == false {
		return false
	}

	return true
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:32,代碼來源:cron.go

示例14: TruncDate

//時間取整
func TruncDate(cyc string, now time.Time) time.Time { // {{{

	//解析周期並取得距下一周期的時間
	switch {
	case cyc == "ss":
		//按秒取整
		return time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local)
	case cyc == "mi":
		//按分鍾取整
		return time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, time.Local)

	case cyc == "h":
		//按小時取整
		return time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, time.Local)
	case cyc == "d":
		//按日取整
		return time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
	case cyc == "m":
		//按月取整
		return time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.Local)
	case cyc == "w":
		//按周取整
		return time.Date(now.Year(), now.Month(), now.Day()-int(now.Weekday()), 0, 0, 0, 0, time.Local)
	case cyc == "q":
		//回頭再處理
	case cyc == "y":
		//按年取整
		return time.Date(now.Year(), 1, 1, 0, 0, 0, 0, time.Local)
	}
	return time.Now()

} // }}}
開發者ID:rprp,項目名稱:hivego,代碼行數:33,代碼來源:util.go

示例15: FmtTimeFull

// FmtTimeFull returns the full time representation of 't' for 'ja'
func (ja *ja) FmtTimeFull(t time.Time) string {

	b := make([]byte, 0, 32)

	b = strconv.AppendInt(b, int64(t.Hour()), 10)
	b = append(b, []byte{0xe6, 0x99, 0x82}...)

	if t.Minute() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Minute()), 10)
	b = append(b, []byte{0xe5, 0x88, 0x86}...)

	if t.Second() < 10 {
		b = append(b, '0')
	}

	b = strconv.AppendInt(b, int64(t.Second()), 10)
	b = append(b, []byte{0xe7, 0xa7, 0x92, 0x20}...)

	tz, _ := t.Zone()

	if btz, ok := ja.timezones[tz]; ok {
		b = append(b, btz...)
	} else {
		b = append(b, tz...)
	}

	return string(b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:32,代碼來源:ja.go


注:本文中的Time.Time.Minute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。