mirror of
https://gitee.com/dromara/carbon.git
synced 2024-11-29 18:57:37 +08:00
v2.1.8 统一私有方法注释格式
This commit is contained in:
parent
2596350c18
commit
8bf93ceb88
@ -214,7 +214,7 @@ func (c Carbon) DiffForHumans(carbon ...Carbon) string {
|
||||
return strings.Replace(c.lang.resources["after"], "%s", translation, 1)
|
||||
}
|
||||
|
||||
// diff gets the difference for unit and value.
|
||||
// gets the difference for unit and value.
|
||||
// 获取相差单位和差值
|
||||
func (c Carbon) diff(end Carbon) (unit string, value int64) {
|
||||
switch true {
|
||||
|
12
errors.go
12
errors.go
@ -4,31 +4,31 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// invalidTimezoneError returns an invalid timezone error.
|
||||
// returns an invalid timezone error.
|
||||
// 无效的时区错误
|
||||
var invalidTimezoneError = func(timezone string) error {
|
||||
return fmt.Errorf("invalid timezone %q, please see the file %q for all valid timezones", timezone, "$GOROOT/lib/time/zoneinfo.zip")
|
||||
}
|
||||
|
||||
// invalidDurationError returns an invalid duration error.
|
||||
// 无效的持续时长错误
|
||||
// returns an invalid duration error.
|
||||
// 无效的时长错误
|
||||
var invalidDurationError = func(duration string) error {
|
||||
return fmt.Errorf("invalid duration %q, please make sure the duration is valid", duration)
|
||||
}
|
||||
|
||||
// invalidValueError returns an invalid value error.
|
||||
// returns an invalid value error.
|
||||
// 无效的时间字符串错误
|
||||
var invalidValueError = func(value string) error {
|
||||
return fmt.Errorf("cannot parse %q as carbon, please make sure the value is valid", value)
|
||||
}
|
||||
|
||||
// invalidLayoutError returns an invalid layout error.
|
||||
// returns an invalid layout error.
|
||||
// 无效的布局模板错误
|
||||
var invalidLayoutError = func(value, layout string) error {
|
||||
return fmt.Errorf("cannot parse %q as carbon by layout %q, please make sure the value and layout match", value, layout)
|
||||
}
|
||||
|
||||
// invalidFormatError returns an invalid format error.
|
||||
// returns an invalid format error.
|
||||
// 无效的格式模板错误
|
||||
var invalidFormatError = func(value, format string) error {
|
||||
return fmt.Errorf("cannot parse %q as carbon by format %q, please make sure the value and format match", value, format)
|
||||
|
14
helper.go
14
helper.go
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// formats common formatting symbols
|
||||
// common formatting symbols
|
||||
// 常规格式化符号
|
||||
var formats = map[byte]string{
|
||||
'd': "02", // Day: Day of the month, 2 digits with leading zeros. Eg: 01 to 31.
|
||||
@ -32,7 +32,7 @@ var formats = map[byte]string{
|
||||
'r': "Thu, 21 Dec 2000 16:01:07 +0200", // Format: RFC 2822 formatted date. Eg: Thu, 21 Dec 2000 16:01:07 +0200.
|
||||
}
|
||||
|
||||
// format2layout converts format to layout.
|
||||
// converts format to layout.
|
||||
// format 转 layout
|
||||
func format2layout(format string) string {
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
@ -41,7 +41,7 @@ func format2layout(format string) string {
|
||||
buffer.WriteString(layout)
|
||||
} else {
|
||||
switch format[i] {
|
||||
case '\\': // 原样输出,不解析
|
||||
case '\\': // raw output, no parse
|
||||
buffer.WriteByte(format[i+1])
|
||||
i++
|
||||
continue
|
||||
@ -53,7 +53,7 @@ func format2layout(format string) string {
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
// getLocationByTimezone gets a Location instance by a timezone string.
|
||||
// gets a Location instance by a timezone string.
|
||||
// 通过时区获取 Location 实例
|
||||
func getLocationByTimezone(timezone string) (*time.Location, error) {
|
||||
loc, err := time.LoadLocation(timezone)
|
||||
@ -63,8 +63,8 @@ func getLocationByTimezone(timezone string) (*time.Location, error) {
|
||||
return loc, err
|
||||
}
|
||||
|
||||
// parseByDuration parses as a Duration instance by a duration string.
|
||||
// 通过持续时长解析
|
||||
// parses as a Duration instance by a duration string.
|
||||
// 通过时长解析
|
||||
func parseByDuration(duration string) (time.Duration, error) {
|
||||
td, err := time.ParseDuration(duration)
|
||||
if err != nil {
|
||||
@ -73,7 +73,7 @@ func parseByDuration(duration string) (time.Duration, error) {
|
||||
return td, err
|
||||
}
|
||||
|
||||
// getAbsValue gets absolute value.
|
||||
// gets absolute value.
|
||||
// 获取绝对值
|
||||
func getAbsValue(value int64) int64 {
|
||||
return (value ^ value>>31) - value>>31
|
||||
|
Loading…
Reference in New Issue
Block a user