carbon
carbon copied to clipboard
A simple, semantic and developer-friendly golang package for time
At present, the following languages are supported * [Simplified Chinese(zh-CN)](./lang/zh-CN.json "Simplified Chinese"):translated by [gouguoyin](https://github.com/gouguoyin "gouguoyin") * [Traditional Chinese(zh-TW)](./lang/zh-TW.json "Traditional Chinese"):translated by [gouguoyin](https://github.com/gouguoyin "gouguoyin") * [English(en)](./lang/en.json "English"):translated by [gouguoyin](https://github.com/gouguoyin "gouguoyin") *...
Hello, I encountered an issue with the following code: ```go lange := carbon.NewLanguage() lange.SetLocale("zh-CN") car := carbon.SetLanguage(lange) if car.Error != nil { log.Printf("Error Info %v\n", car.Error) return } offDutyTime :=...
#134 Adapted function "ToLayoutString" -> requires some code review and output testing! ``` log.Println(carbon.Now().SetLocale("en").Layout("02 January 2006")) log.Println(carbon.Now().SetLocale("ro").Layout("02 January 2006")) log.Println(carbon.Now().SetLocale("ru").Layout("02 January 2006")) log.Println(carbon.Now().SetLocale("zh-CN").Layout("02 January 2006")) ``` ``` The expected Output...
The Parse() method cannot parse a time string when the month or date less than 10 is not preceded by 0, like this: `2022-5-18` Code sample: ``` carbon.Parse("2020-8-05").ToDateTimeString() // empty...
Hello, I encountered an issue with the following code: ```go carbon.Parse("2022-08-08 22:55:15").DiffInMonths(carbon.Parse("2022-09-18 22:55:19")) carbon.Parse("2022-09-18 22:55:19").DiffInMonths(carbon.Parse("2022-08-08 22:55:15")) ``` golang version: **sgo1.19.1 darwin/arm64** carbon version: **v2.1.9** time zone: **such as Japan** I...
下面这种方式可以很好地兼容 分隔符 和 0补位 两种日期格式,而不是有了分隔符还需要0补位 ` var dateFieldLens = [9]int{4, 2, 2, 2, 2, 2, 9, 2, 2} // ParseGeneralDate 解析任意字段有序的日期 // 顺序必须是:年月日时分秒纳秒,兼容ISO8601UTC时区 // 时间字段可以是任意分隔符或填充位数,示例如下: // 2022年8月21日19点18分38秒123456789纳秒 // 20220821191838.123456789 //...
Reverts golang-module/carbon#221
`IsToday()`, `IsYesterday()`, and `IsTomorrow()` functions in the `carbon` package. These functions are based on local time, which can lead to incorrect results when used in different time zones. For example,...
```golang type Person struct { Name string `json:"name"` Age int `json:"age"` Field1 carbon.Carbon `json:"field1" carbon:"type:date" tz:"PRC"` Field2 carbon.Carbon `json:"field2" carbon:"type:time" tz:"PRC"` Field3 carbon.Carbon `json:"field3" carbon:"type:dateTime" tz:"PRC"` } list := make([]models.Person,...