Skip to content

Commit 49d468b

Browse files
committed
Merge remote-tracking branch 'origin/v2.3.2'
2 parents 4a5290d + 652c5f1 commit 49d468b

14 files changed

+413
-248
lines changed

README.cn.md

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ carbon.ParseByLayout("2020-08-05 13:14:15", "2006-01-02 15:04:05", carbon.Tokyo)
236236

237237
```go
238238
// 将 time.Time 转换成 Carbon
239-
carbon.CreateFromStdTime(time.Now())
239+
carbon.CreateFromStdTime(time.Now(), "PRC")
240240
// 将 Carbon 转换成 time.Time
241241
carbon.Now().ToStdTime()
242242
```
@@ -1267,13 +1267,15 @@ type Person struct {
12671267
Name string `json:"name"`
12681268
Age int `json:"age"`
12691269

1270-
Birthday0 Carbon `json:"birthday0"`
1271-
Birthday1 Carbon `json:"birthday1" carbon:"date"`
1272-
Birthday2 Carbon `json:"birthday2" carbon:"time"`
1273-
Birthday3 Carbon `json:"birthday3" carbon:"dateTime"`
1274-
Birthday4 Carbon `json:"birthday4" carbon:"date" tz:"PRC"`
1275-
Birthday5 Carbon `json:"birthday5" carbon:"time" tz:"PRC"`
1276-
Birthday6 Carbon `json:"birthday6" carbon:"dateTime" tz:"PRC"`
1270+
Birthday1 Carbon `json:"birthday1"`
1271+
Birthday2 Carbon `json:"birthday2" carbon:"date" tz:"PRC"`
1272+
Birthday3 Carbon `json:"birthday3" carbon:"time" tz:"PRC"`
1273+
Birthday4 Carbon `json:"birthday4" carbon:"dateTime" tz:"PRC"`
1274+
1275+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1276+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1277+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1278+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
12771279
}
12781280
```
12791281

@@ -1284,13 +1286,15 @@ type Person struct {
12841286
Name string `json:"name"`
12851287
Age int `json:"age"`
12861288

1287-
Birthday0 Carbon `json:"birthday0"`
1288-
Birthday1 Carbon `json:"birthday1" carbon:"layout:2006-01-02"`
1289-
Birthday2 Carbon `json:"birthday2" carbon:"layout:15:04:05"`
1290-
Birthday3 Carbon `json:"birthday3" carbon:"layout:2006-01-02 15:04:05"`
1291-
Birthday4 Carbon `json:"birthday4" carbon:"layout:2006-01-02" tz:"PRC"`
1292-
Birthday5 Carbon `json:"birthday5" carbon:"layout:15:04:05" tz:"PRC"`
1293-
Birthday6 Carbon `json:"birthday6" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
1289+
Birthday1 Carbon `json:"birthday1"`
1290+
Birthday2 Carbon `json:"birthday2" carbon:"layout:2006-01-02" tz:"PRC"`
1291+
Birthday3 Carbon `json:"birthday3" carbon:"layout:15:04:05" tz:"PRC"`
1292+
Birthday4 Carbon `json:"birthday4" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
1293+
1294+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1295+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1296+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1297+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
12941298
}
12951299
```
12961300

@@ -1301,13 +1305,15 @@ type Person struct {
13011305
Name string `json:"name"`
13021306
Age int `json:"age"`
13031307

1304-
Birthday0 Carbon `json:"birthday0"`
1305-
Birthday1 Carbon `json:"birthday1" carbon:"format:Y-m-d"`
1306-
Birthday2 Carbon `json:"birthday2" carbon:"format:H:i:s"`
1307-
Birthday3 Carbon `json:"birthday3" carbon:"format:Y-m-d H:i:s"`
1308-
Birthday4 Carbon `json:"birthday4" carbon:"format:Y-m-d" tz:"PRC"`
1309-
Birthday5 Carbon `json:"birthday5" carbon:"format:H:i:s" tz:"PRC"`
1310-
Birthday6 Carbon `json:"birthday6" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
1308+
Birthday1 Carbon `json:"birthday1"`
1309+
Birthday2 Carbon `json:"birthday2" carbon:"format:Y-m-d" tz:"PRC"`
1310+
Birthday3 Carbon `json:"birthday3" carbon:"format:H:i:s" tz:"PRC"`
1311+
Birthday4 Carbon `json:"birthday4" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
1312+
1313+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1314+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1315+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1316+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
13111317
}
13121318
```
13131319

@@ -1321,13 +1327,14 @@ person := Person {
13211327
Name: "gouguoyin",
13221328
Age: 18,
13231329

1324-
Birthday0: now,
13251330
Birthday1: now,
13261331
Birthday2: now,
13271332
Birthday3: now,
13281333
Birthday4: now,
13291334
Birthday5: now,
13301335
Birthday6: now,
1336+
Birthday7: now,
1337+
Birthday8: now,
13311338
}
13321339
```
13331340

@@ -1349,13 +1356,14 @@ fmt.Printf("%s", data)
13491356
{
13501357
"name": "gouguoyin",
13511358
"age": 18,
1352-
"birthday0": "2020-08-05 13:14:15",
1353-
"birthday1": "2020-08-05",
1354-
"birthday2": "13:14:15",
1355-
"birthday3": "2020-08-05 13:14:15",
1356-
"birthday4": "2020-08-05",
1357-
"birthday5": "213:14:15",
1358-
"birthday6": "2020-08-05 13:14:15"
1359+
"birthday1": "2020-08-05 13:14:15",
1360+
"birthday2": "2020-08-05",
1361+
"birthday3": "13:14:15",
1362+
"birthday4": "2020-08-05 13:14:15",
1363+
"birthday5": 1596604455,
1364+
"birthday6": 1596604455999,
1365+
"birthday7": 1596604455999999,
1366+
"birthday8": 1596604455999999999
13591367
}
13601368
```
13611369

@@ -1365,13 +1373,14 @@ fmt.Printf("%s", data)
13651373
str := `{
13661374
"name": "gouguoyin",
13671375
"age": 18,
1368-
"birthday0": "2020-08-05 13:14:15",
1369-
"birthday1": "2020-08-05",
1370-
"birthday2": "13:14:15",
1371-
"birthday3": "2020-08-05 13:14:15",
1372-
"birthday4": "2020-08-05",
1373-
"birthday5": "213:14:15",
1374-
"birthday6": "2020-08-05 13:14:15"
1376+
"birthday1": "2020-08-05 13:14:15",
1377+
"birthday2": "2020-08-05",
1378+
"birthday3": "13:14:15",
1379+
"birthday4": "2020-08-05 13:14:15",
1380+
"birthday5": 1596604455,
1381+
"birthday6": 1596604455999,
1382+
"birthday7": 1596604455999999,
1383+
"birthday8": 1596604455999999999
13751384
}`
13761385
var person Person
13771386

@@ -1387,13 +1396,15 @@ if unmarshalErr != nil {
13871396
log.Fatal(unmarshalErr)
13881397
}
13891398

1390-
fmt.Sprintf("%s", person.Birthday0) // 2002-08-05 13:14:15
1391-
fmt.Sprintf("%s", person.Birthday1) // 2020-08-05
1392-
fmt.Sprintf("%s", person.Birthday2) // 13:14:15
1393-
fmt.Sprintf("%s", person.Birthday3) // 2002-08-05 13:14:15
1394-
fmt.Sprintf("%s", person.Birthday4) // 2002-08-05
1395-
fmt.Sprintf("%s", person.Birthday5) // 13:14:15
1396-
fmt.Sprintf("%s", person.Birthday6) // 2002-08-05 13:14:15
1399+
fmt.Sprintf("%s", person.Birthday1) // 2002-08-05 13:14:15
1400+
fmt.Sprintf("%s", person.Birthday2) // 2020-08-05
1401+
fmt.Sprintf("%s", person.Birthday3) // 13:14:15
1402+
fmt.Sprintf("%s", person.Birthday4) // 2002-08-05 13:14:15
1403+
1404+
fmt.Sprintf("%d", person.Birthday5) // 1596604455
1405+
fmt.Sprintf("%d", person.Birthday6) // 1596604455999
1406+
fmt.Sprintf("%d", person.Birthday7) // 1596604455999999
1407+
fmt.Sprintf("%d", person.Birthday8) // 1596604455999999999
13971408
```
13981409

13991410
##### 国际化

README.jp.md

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ carbon.ParseByLayout("2020-08-05 13:14:15", "2006-01-02 15:04:05", carbon.Tokyo)
236236

237237
```go
238238
// time.Time を Carbon に変換します
239-
carbon.CreateFromStdTime(time.Now())
239+
carbon.CreateFromStdTime(time.Now(), "PRC")
240240
// Carbon を time.Time に変換します
241241
carbon.Now().ToStdTime()
242242
```
@@ -1267,13 +1267,15 @@ type Person struct {
12671267
Name string `json:"name"`
12681268
Age int `json:"age"`
12691269

1270-
Birthday0 Carbon `json:"birthday0"`
1271-
Birthday1 Carbon `json:"birthday1" carbon:"date"`
1272-
Birthday2 Carbon `json:"birthday2" carbon:"time"`
1273-
Birthday3 Carbon `json:"birthday3" carbon:"dateTime"`
1274-
Birthday4 Carbon `json:"birthday4" carbon:"date" tz:"PRC"`
1275-
Birthday5 Carbon `json:"birthday5" carbon:"time" tz:"PRC"`
1276-
Birthday6 Carbon `json:"birthday6" carbon:"dateTime" tz:"PRC"`
1270+
Birthday1 Carbon `json:"birthday1"`
1271+
Birthday2 Carbon `json:"birthday2" carbon:"date" tz:"PRC"`
1272+
Birthday3 Carbon `json:"birthday3" carbon:"time" tz:"PRC"`
1273+
Birthday4 Carbon `json:"birthday4" carbon:"dateTime" tz:"PRC"`
1274+
1275+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1276+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1277+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1278+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
12771279
}
12781280
```
12791281

@@ -1284,13 +1286,15 @@ type Person struct {
12841286
Name string `json:"name"`
12851287
Age int `json:"age"`
12861288

1287-
Birthday0 Carbon `json:"birthday0"`
1288-
Birthday1 Carbon `json:"birthday1" carbon:"layout:2006-01-02"`
1289-
Birthday2 Carbon `json:"birthday2" carbon:"layout:15:04:05"`
1290-
Birthday3 Carbon `json:"birthday3" carbon:"layout:2006-01-02 15:04:05"`
1291-
Birthday4 Carbon `json:"birthday4" carbon:"layout:2006-01-02" tz:"PRC"`
1292-
Birthday5 Carbon `json:"birthday5" carbon:"layout:15:04:05" tz:"PRC"`
1293-
Birthday6 Carbon `json:"birthday6" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
1289+
Birthday1 Carbon `json:"birthday1"`
1290+
Birthday2 Carbon `json:"birthday2" carbon:"layout:2006-01-02" tz:"PRC"`
1291+
Birthday3 Carbon `json:"birthday3" carbon:"layout:15:04:05" tz:"PRC"`
1292+
Birthday4 Carbon `json:"birthday4" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
1293+
1294+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1295+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1296+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1297+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
12941298
}
12951299
```
12961300

@@ -1301,13 +1305,15 @@ type Person struct {
13011305
Name string `json:"name"`
13021306
Age int `json:"age"`
13031307

1304-
Birthday0 Carbon `json:"birthday0"`
1305-
Birthday1 Carbon `json:"birthday1" carbon:"format:Y-m-d"`
1306-
Birthday2 Carbon `json:"birthday2" carbon:"format:H:i:s"`
1307-
Birthday3 Carbon `json:"birthday3" carbon:"format:Y-m-d H:i:s"`
1308-
Birthday4 Carbon `json:"birthday4" carbon:"format:Y-m-d" tz:"PRC"`
1309-
Birthday5 Carbon `json:"birthday5" carbon:"format:H:i:s" tz:"PRC"`
1310-
Birthday6 Carbon `json:"birthday6" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
1308+
Birthday1 Carbon `json:"birthday1"`
1309+
Birthday2 Carbon `json:"birthday2" carbon:"format:Y-m-d" tz:"PRC"`
1310+
Birthday3 Carbon `json:"birthday3" carbon:"format:H:i:s" tz:"PRC"`
1311+
Birthday4 Carbon `json:"birthday4" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
1312+
1313+
Birthday5 Carbon `json:"birthday5" carbon:"timestamp" tz:"PRC"`
1314+
Birthday6 Carbon `json:"birthday6" carbon:"timestampMilli" tz:"PRC"`
1315+
Birthday7 Carbon `json:"birthday7" carbon:"timestampMicro" tz:"PRC"`
1316+
Birthday8 Carbon `json:"birthday8" carbon:"timestampNano" tz:"PRC"`
13111317
}
13121318
```
13131319

@@ -1317,14 +1323,15 @@ now := Parse("2020-08-05 13:14:15", PRC)
13171323
person := Person {
13181324
Name: "gouguoyin",
13191325
Age: 18,
1320-
1321-
Birthday0: now,
1322-
Birthday1: now,
1326+
1327+
Birthday1: now,
13231328
Birthday2: now,
13241329
Birthday3: now,
13251330
Birthday4: now,
13261331
Birthday5: now,
13271332
Birthday6: now,
1333+
Birthday7: now,
1334+
Birthday8: now,
13281335
}
13291336
```
13301337

@@ -1346,13 +1353,14 @@ fmt.Printf("%s", data)
13461353
{
13471354
"name": "gouguoyin",
13481355
"age": 18,
1349-
"birthday0": "2020-08-05 13:14:15",
1350-
"birthday1": "2020-08-05",
1351-
"birthday2": "13:14:15",
1352-
"birthday3": "2020-08-05 13:14:15",
1353-
"birthday4": "2020-08-05",
1354-
"birthday5": "213:14:15",
1355-
"birthday6": "2020-08-05 13:14:15"
1356+
"birthday1": "2020-08-05 13:14:15",
1357+
"birthday2": "2020-08-05",
1358+
"birthday3": "13:14:15",
1359+
"birthday4": "2020-08-05 13:14:15",
1360+
"birthday5": 1596604455,
1361+
"birthday6": 1596604455999,
1362+
"birthday7": 1596604455999999,
1363+
"birthday8": 1596604455999999999
13561364
}
13571365
```
13581366

@@ -1362,13 +1370,14 @@ fmt.Printf("%s", data)
13621370
str := `{
13631371
"name": "gouguoyin",
13641372
"age": 18,
1365-
"birthday0": "2020-08-05 13:14:15",
1366-
"birthday1": "2020-08-05",
1367-
"birthday2": "13:14:15",
1368-
"birthday3": "2020-08-05 13:14:15",
1369-
"birthday4": "2020-08-05",
1370-
"birthday5": "213:14:15",
1371-
"birthday6": "2020-08-05 13:14:15"
1373+
"birthday1": "2020-08-05 13:14:15",
1374+
"birthday2": "2020-08-05",
1375+
"birthday3": "13:14:15",
1376+
"birthday4": "2020-08-05 13:14:15",
1377+
"birthday5": 1596604455,
1378+
"birthday6": 1596604455999,
1379+
"birthday7": 1596604455999999,
1380+
"birthday8": 1596604455999999999
13721381
}`
13731382
var person Person
13741383

@@ -1384,13 +1393,15 @@ if unmarshalErr != nil {
13841393
log.Fatal(unmarshalErr)
13851394
}
13861395

1387-
fmt.Sprintf("%s", person.Birthday0) // 2002-08-05 13:14:15
1388-
fmt.Sprintf("%s", person.Birthday1) // 2020-08-05
1389-
fmt.Sprintf("%s", person.Birthday2) // 13:14:15
1390-
fmt.Sprintf("%s", person.Birthday3) // 2002-08-05 13:14:15
1391-
fmt.Sprintf("%s", person.Birthday4) // 2002-08-05
1392-
fmt.Sprintf("%s", person.Birthday5) // 13:14:15
1393-
fmt.Sprintf("%s", person.Birthday6) // 2002-08-05 13:14:15
1396+
fmt.Sprintf("%s", person.Birthday1) // 2002-08-05 13:14:15
1397+
fmt.Sprintf("%s", person.Birthday2) // 2020-08-05
1398+
fmt.Sprintf("%s", person.Birthday3) // 13:14:15
1399+
fmt.Sprintf("%s", person.Birthday4) // 2002-08-05 13:14:15
1400+
1401+
fmt.Sprintf("%d", person.Birthday5) // 1596604455
1402+
fmt.Sprintf("%d", person.Birthday6) // 1596604455999
1403+
fmt.Sprintf("%d", person.Birthday7) // 1596604455999999
1404+
fmt.Sprintf("%d", person.Birthday8) // 1596604455999999999
13941405
```
13951406

13961407
##### 国際化

0 commit comments

Comments
 (0)