@@ -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 に変換します
241241carbon.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)
13171323person := 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)
13621370str := ` {
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}`
13731382var 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