From 492670d0f26e4818036a26b6890968f6191bac5a Mon Sep 17 00:00:00 2001 From: gouguoyin <245629560@qq.com> Date: Sat, 7 May 2022 06:57:43 +0000 Subject: [PATCH] =?UTF-8?q?v2.1.6=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.cn.md | 93 ++++++++++++++++++++++++------------------------- README.jp.md | 97 ++++++++++++++++++++++++++-------------------------- README.md | 28 +++++++-------- 3 files changed, 110 insertions(+), 108 deletions(-) diff --git a/README.cn.md b/README.cn.md index 91b46a5..b1504c4 100644 --- a/README.cn.md +++ b/README.cn.md @@ -1185,41 +1185,42 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true ```go type Person struct { -Name string `json:"name"` -Age int `json:"age"` -Birthday1 carbon.DateTime `json:"birthday"` -Birthday2 carbon.DateTimeMilli `json:"birthday"` -Birthday3 carbon.DateTimeMicro `json:"birthday"` -Birthday4 carbon.DateTimeNano `json:"birthday"` -GraduatedAt1 carbon.Date `json:"graduated_at"` -GraduatedAt2 carbon.DateMilli `json:"graduated_at"` -GraduatedAt3 carbon.DateMicro `json:"graduated_at"` -GraduatedAt4 carbon.DateNano `json:"graduated_at"` -CreatedAt1 carbon.Timestamp `json:"created_at1"` -CreatedAt2 carbon.TimestampMilli `json:"created_at2"` -CreatedAt3 carbon.TimestampMicro `json:"created_at3"` -CreatedAt4 carbon.TimestampNano `json:"created_at4"` + Name string `json:"name"` + Age int `json:"age"` + Birthday1 carbon.DateTime `json:"birthday"` + Birthday2 carbon.DateTimeMilli `json:"birthday"` + Birthday3 carbon.DateTimeMicro `json:"birthday"` + Birthday4 carbon.DateTimeNano `json:"birthday"` + GraduatedAt1 carbon.Date `json:"graduated_at"` + GraduatedAt2 carbon.DateMilli `json:"graduated_at"` + GraduatedAt3 carbon.DateMicro `json:"graduated_at"` + GraduatedAt4 carbon.DateNano `json:"graduated_at"` + CreatedAt1 carbon.Timestamp `json:"created_at1"` + CreatedAt2 carbon.TimestampMilli `json:"created_at2"` + CreatedAt3 carbon.TimestampMicro `json:"created_at3"` + CreatedAt4 carbon.TimestampNano `json:"created_at4"` } ``` ###### 实例化模型 ```go +now := carbon.Now() person := Person { -Name: "gouguoyin", -Age: 18, -Birthday1: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday2: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday3: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday4: carbon.DateTime{carbon.Now().SubYears(18)}, -GraduatedAt1: carbon.Date{carbon.Now()}, -GraduatedAt2: carbon.Date{carbon.Now()}, -GraduatedAt3: carbon.Date{carbon.Now()}, -GraduatedAt4: carbon.Date{carbon.Now()}, -CreatedAt1: carbon.Timestamp{carbon.Now()}, -CreatedAt2: carbon.TimestampMilli{carbon.Now()}, -CreatedAt3: carbon.TimestampMicro{carbon.Now()}, -CreatedAt4: carbon.TimestampNano{carbon.Now()}, + Name: "gouguoyin", + Age: 18, + Birthday1: carbon.DateTime{now.SubYears(18)}, + Birthday2: carbon.DateTime{now.SubYears(18)}, + Birthday3: carbon.DateTime{now.SubYears(18)}, + Birthday4: carbon.DateTime{now.SubYears(18)}, + GraduatedAt1: carbon.Date{now}, + GraduatedAt2: carbon.Date{now}, + GraduatedAt3: carbon.Date{now}, + GraduatedAt4: carbon.Date{now}, + CreatedAt1: carbon.Timestamp{now}, + CreatedAt2: carbon.TimestampMilli{now}, + CreatedAt3: carbon.TimestampMicro{now}, + CreatedAt4: carbon.TimestampNano{now}, } ``` @@ -1228,26 +1229,26 @@ CreatedAt4: carbon.TimestampNano{carbon.Now()}, ```go data, err := json.Marshal(&person) if err != nil { -// 错误处理 -log.Fatal(err) + // 错误处理 + log.Fatal(err) } fmt.Printf("%s", data) // 输出 { -"name": "gouguoyin", -"age": 18, -"birthday1": "2003-07-16 16:22:02", -"birthday2": "2003-07-16 16:22:02.999", -"birthday3": "2003-07-16 16:22:02.999999", -"birthday4": "2003-07-16 16:22:02.999999999", -"graduated_at1": "2020-08-05", -"graduated_at2": "2020-08-05.999", -"graduated_at3": "2020-08-05.999999", -"graduated_at4": "2020-08-05.999999999", -"created_at1": 1596604455, -"created_at2": 1596604455999, -"created_at3": 1596604455999999, -"created_at4": 1596604455999999999 + "name": "gouguoyin", + "age": 18, + "birthday1": "2003-07-16 16:22:02", + "birthday2": "2003-07-16 16:22:02.999", + "birthday3": "2003-07-16 16:22:02.999999", + "birthday4": "2003-07-16 16:22:02.999999999", + "graduated_at1": "2020-08-05", + "graduated_at2": "2020-08-05.999", + "graduated_at3": "2020-08-05.999999", + "graduated_at4": "2020-08-05.999999999", + "created_at1": 1596604455, + "created_at2": 1596604455999, + "created_at3": 1596604455999999, + "created_at4": 1596604455999999999 } ``` @@ -1273,8 +1274,8 @@ str := `{ person := new(Person) err := json.Unmarshal([]byte(str), &person) if err != nil { -// 错误处理 -log.Fatal(err) + // 错误处理 + log.Fatal(err) } fmt.Printf("%+v", *person) // 输出 diff --git a/README.jp.md b/README.jp.md index 90eda10..3bcc6c4 100644 --- a/README.jp.md +++ b/README.jp.md @@ -1181,41 +1181,42 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true ```go type Person struct { -Name string `json:"name"` -Age int `json:"age"` -Birthday1 carbon.DateTime `json:"birthday"` -Birthday2 carbon.DateTimeMilli `json:"birthday"` -Birthday3 carbon.DateTimeMicro `json:"birthday"` -Birthday4 carbon.DateTimeNano `json:"birthday"` -GraduatedAt1 carbon.Date `json:"graduated_at"` -GraduatedAt2 carbon.DateMilli `json:"graduated_at"` -GraduatedAt3 carbon.DateMicro `json:"graduated_at"` -GraduatedAt4 carbon.DateNano `json:"graduated_at"` -CreatedAt1 carbon.Timestamp `json:"created_at1"` -CreatedAt2 carbon.TimestampMilli `json:"created_at2"` -CreatedAt3 carbon.TimestampMicro `json:"created_at3"` -CreatedAt4 carbon.TimestampNano `json:"created_at4"` + Name string `json:"name"` + Age int `json:"age"` + Birthday1 carbon.DateTime `json:"birthday"` + Birthday2 carbon.DateTimeMilli `json:"birthday"` + Birthday3 carbon.DateTimeMicro `json:"birthday"` + Birthday4 carbon.DateTimeNano `json:"birthday"` + GraduatedAt1 carbon.Date `json:"graduated_at"` + GraduatedAt2 carbon.DateMilli `json:"graduated_at"` + GraduatedAt3 carbon.DateMicro `json:"graduated_at"` + GraduatedAt4 carbon.DateNano `json:"graduated_at"` + CreatedAt1 carbon.Timestamp `json:"created_at1"` + CreatedAt2 carbon.TimestampMilli `json:"created_at2"` + CreatedAt3 carbon.TimestampMicro `json:"created_at3"` + CreatedAt4 carbon.TimestampNano `json:"created_at4"` } ``` ###### 初期化モデル ```go +now := carbon.Now() person := Person { -Name: "gouguoyin", -Age: 18, -Birthday1: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday2: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday3: carbon.DateTime{carbon.Now().SubYears(18)}, -Birthday4: carbon.DateTime{carbon.Now().SubYears(18)}, -GraduatedAt1: carbon.Date{carbon.Now()}, -GraduatedAt2: carbon.Date{carbon.Now()}, -GraduatedAt3: carbon.Date{carbon.Now()}, -GraduatedAt4: carbon.Date{carbon.Now()}, -CreatedAt1: carbon.Timestamp{carbon.Now()}, -CreatedAt2: carbon.TimestampMilli{carbon.Now()}, -CreatedAt3: carbon.TimestampMicro{carbon.Now()}, -CreatedAt4: carbon.TimestampNano{carbon.Now()}, + Name: "gouguoyin", + Age: 18, + Birthday1: carbon.DateTime{now.SubYears(18)}, + Birthday2: carbon.DateTime{now.SubYears(18)}, + Birthday3: carbon.DateTime{now.SubYears(18)}, + Birthday4: carbon.DateTime{now.SubYears(18)}, + GraduatedAt1: carbon.Date{now}, + GraduatedAt2: carbon.Date{now}, + GraduatedAt3: carbon.Date{now}, + GraduatedAt4: carbon.Date{now}, + CreatedAt1: carbon.Timestamp{now}, + CreatedAt2: carbon.TimestampMilli{now}, + CreatedAt3: carbon.TimestampMicro{now}, + CreatedAt4: carbon.TimestampNano{now}, } ``` @@ -1224,26 +1225,26 @@ CreatedAt4: carbon.TimestampNano{carbon.Now()}, ```go data, err := json.Marshal(&person) if err != nil { -// エラー処理... -log.Fatal(c.Error) + // エラー処理... + log.Fatal(c.Error) } fmt.Printf("%s", data) // 出力 { -"name": "gouguoyin", -"age": 18, -"birthday1": "2003-07-16 16:22:02", -"birthday2": "2003-07-16 16:22:02.999", -"birthday3": "2003-07-16 16:22:02.999999", -"birthday4": "2003-07-16 16:22:02.999999999", -"graduated_at1": "2020-08-05", -"graduated_at2": "2020-08-05.999", -"graduated_at3": "2020-08-05.999999", -"graduated_at4": "2020-08-05.999999999", -"created_at1": 1596604455, -"created_at2": 1596604455999, -"created_at3": 1596604455999999, -"created_at4": 1596604455999999999 + "name": "gouguoyin", + "age": 18, + "birthday1": "2003-07-16 16:22:02", + "birthday2": "2003-07-16 16:22:02.999", + "birthday3": "2003-07-16 16:22:02.999999", + "birthday4": "2003-07-16 16:22:02.999999999", + "graduated_at1": "2020-08-05", + "graduated_at2": "2020-08-05.999", + "graduated_at3": "2020-08-05.999999", + "graduated_at4": "2020-08-05.999999999", + "created_at1": 1596604455, + "created_at2": 1596604455999, + "created_at3": 1596604455999999, + "created_at4": 1596604455999999999 } ``` @@ -1269,8 +1270,8 @@ str := `{ person := new(Person) err := json.Unmarshal([]byte(str), &person) if err != nil { -// エラー処理... -log.Fatal(c.Error) + // エラー処理... + log.Fatal(c.Error) } fmt.Printf("%+v", *person) // 出力 @@ -1311,8 +1312,8 @@ lang.SetLocale("jp") c := carbon.SetLanguage(lang) if c.Error != nil { -// エラー処理 -log.Fatal(err) + // エラー処理 + log.Fatal(err) } c.Now().AddHours(1).DiffForHumans() // 1 時間後 diff --git a/README.md b/README.md index 7065fe7..30c30ac 100644 --- a/README.md +++ b/README.md @@ -1180,20 +1180,20 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true ```go type Person struct { -Name string `json:"name"` -Age int `json:"age"` -Birthday1 carbon.DateTime `json:"birthday"` -Birthday2 carbon.DateTimeMilli `json:"birthday"` -Birthday3 carbon.DateTimeMicro `json:"birthday"` -Birthday4 carbon.DateTimeNano `json:"birthday"` -GraduatedAt1 carbon.Date `json:"graduated_at"` -GraduatedAt2 carbon.DateMilli `json:"graduated_at"` -GraduatedAt3 carbon.DateMicro `json:"graduated_at"` -GraduatedAt4 carbon.DateNano `json:"graduated_at"` -CreatedAt1 carbon.Timestamp `json:"created_at1"` -CreatedAt2 carbon.TimestampMilli `json:"created_at2"` -CreatedAt3 carbon.TimestampMicro `json:"created_at3"` -CreatedAt4 carbon.TimestampNano `json:"created_at4"` + Name string `json:"name"` + Age int `json:"age"` + Birthday1 carbon.DateTime `json:"birthday"` + Birthday2 carbon.DateTimeMilli `json:"birthday"` + Birthday3 carbon.DateTimeMicro `json:"birthday"` + Birthday4 carbon.DateTimeNano `json:"birthday"` + GraduatedAt1 carbon.Date `json:"graduated_at"` + GraduatedAt2 carbon.DateMilli `json:"graduated_at"` + GraduatedAt3 carbon.DateMicro `json:"graduated_at"` + GraduatedAt4 carbon.DateNano `json:"graduated_at"` + CreatedAt1 carbon.Timestamp `json:"created_at1"` + CreatedAt2 carbon.TimestampMilli `json:"created_at2"` + CreatedAt3 carbon.TimestampMicro `json:"created_at3"` + CreatedAt4 carbon.TimestampNano `json:"created_at4"` } ```