当前位置: 首页>>代码示例>>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;未经允许,请勿转载。