-
-
Notifications
You must be signed in to change notification settings - Fork 240
/
encoding.go
660 lines (573 loc) · 18.1 KB
/
encoding.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
package carbon
import (
"bytes"
"fmt"
"strconv"
)
// DateTime defines a DateTime struct.
// 定义 DateTime 结构体
type DateTime struct {
Carbon
}
// DateTimeMilli defines a DateTimeMilli struct.
// 定义 DateTimeMilli 结构体
type DateTimeMilli struct {
Carbon
}
// DateTimeMicro defines a DateTimeMicro struct.
// 定义 DateTimeMicro 结构体
type DateTimeMicro struct {
Carbon
}
// DateTimeNano defines a DateTimeNano struct.
// 定义 DateTimeNano 结构体
type DateTimeNano struct {
Carbon
}
// Date defines a Date struct.
// 定义 Date 结构体
type Date struct {
Carbon
}
// DateMilli defines a DateMilli struct.
// 定义 DateMilli 结构体
type DateMilli struct {
Carbon
}
// DateMicro defines a DateMicro struct.
// 定义 DateMicro 结构体
type DateMicro struct {
Carbon
}
// DateNano defines a DateNano struct.
// 定义 DateNano 结构体
type DateNano struct {
Carbon
}
// Time defines a Time struct.
// 定义 Time 结构体
type Time struct {
Carbon
}
// TimeMilli defines a TimeMilli struct.
// 定义 TimeMilli 结构体
type TimeMilli struct {
Carbon
}
// TimeMicro defines a TimeMicro struct.
// 定义 TimeMicro 结构体
type TimeMicro struct {
Carbon
}
// TimeNano defines a TimeNano struct.
// 定义 TimeNano 结构体
type TimeNano struct {
Carbon
}
// Timestamp defines a Timestamp struct.
// 定义 Timestamp 结构体
type Timestamp struct {
Carbon
}
// TimestampMilli defines a TimestampMilli struct.
// 定义 TimestampMilli 结构体
type TimestampMilli struct {
Carbon
}
// TimestampMicro defines a TimestampMicro struct.
// 定义 TimestampMicro 结构体
type TimestampMicro struct {
Carbon
}
// TimestampNano defines a TimestampNano struct.
// 定义 TimestampNano 结构体
type TimestampNano struct {
Carbon
}
// MarshalJSON implements the interface json.Marshal for Carbon struct.
// 实现 json.Marshaler 接口
func (c Carbon) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, c.Layout(c.layout, c.Location()))), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for Carbon struct.
// 实现 json.Unmarshaler 接口
func (c *Carbon) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
*c = ParseByLayout(value, c.layout, c.Location())
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateTime struct.
// 实现 MarshalJSON 接口
func (t DateTime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateTime struct.
// 实现 UnmarshalJSON 接口
func (t *DateTime) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateTimeLayout, t.Location())
if c.Error == nil {
*t = DateTime{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateTimeMilli struct.
// 实现 MarshalJSON 接口
func (t DateTimeMilli) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeMilliString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateTimeMilli struct.
// 实现 UnmarshalJSON 接口
func (t *DateTimeMilli) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateTimeMilliLayout, t.Location())
if c.Error == nil {
*t = DateTimeMilli{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateTimeMicro struct.
// 实现 MarshalJSON 接口
func (t DateTimeMicro) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeMicroString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateTimeMicro struct.
// 实现 UnmarshalJSON 接口
func (t *DateTimeMicro) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateTimeMicroLayout, t.Location())
if c.Error == nil {
*t = DateTimeMicro{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateTimeNano struct.
// 实现 MarshalJSON 接口
func (t DateTimeNano) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeNanoString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateTimeNano struct.
// 实现 UnmarshalJSON 接口
func (t *DateTimeNano) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateTimeNanoLayout, t.Location())
if c.Error == nil {
*t = DateTimeNano{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for Date struct.
// 实现 MarshalJSON 接口
func (t Date) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for Date struct.
// 实现 UnmarshalJSON 接口
func (t *Date) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateLayout, t.Location())
if c.Error == nil {
*t = Date{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateMilli struct.
// 实现 MarshalJSON 接口
func (t DateMilli) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateMilliString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateMilli struct.
// 实现 UnmarshalJSON 接口
func (t *DateMilli) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateMilliLayout, t.Location())
if c.Error == nil {
*t = DateMilli{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateMicro struct.
// 实现 MarshalJSON 接口
func (t DateMicro) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateMicroString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateMicro struct.
// 实现 UnmarshalJSON 接口
func (t *DateMicro) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateMicroLayout, t.Location())
if c.Error == nil {
*t = DateMicro{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for DateNano struct.
// 实现 MarshalJSON 接口
func (t DateNano) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToDateNanoString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for DateNano struct.
// 实现 UnmarshalJSON 接口
func (t *DateNano) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, DateNanoLayout, t.Location())
if c.Error == nil {
*t = DateNano{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for Time struct.
// 实现 MarshalJSON 接口
func (t Time) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToTimeString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for Time struct.
// 实现 UnmarshalJSON 接口
func (t *Time) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, TimeLayout, t.Location())
if c.Error == nil {
*t = Time{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for TimeMilli struct.
// 实现 MarshalJSON 接口
func (t TimeMilli) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToTimeMilliString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimeMilli struct.
// 实现 UnmarshalJSON 接口
func (t *TimeMilli) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, TimeMilliLayout, t.Location())
if c.Error == nil {
*t = TimeMilli{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for TimeMicro struct.
// 实现 MarshalJSON 接口
func (t TimeMicro) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToTimeMicroString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimeMicro struct.
// 实现 UnmarshalJSON 接口
func (t *TimeMicro) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, TimeMicroLayout, t.Location())
if c.Error == nil {
*t = TimeMicro{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for TimeNano struct.
// 实现 MarshalJSON 接口
func (t TimeNano) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, t.ToTimeNanoString())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimeNano struct.
// 实现 UnmarshalJSON 接口
func (t *TimeNano) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
c := ParseByLayout(value, TimeNanoLayout, t.Location())
if c.Error == nil {
*t = TimeNano{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for Timestamp struct.
// 实现 MarshalJSON 接口
func (t Timestamp) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`%d`, t.Timestamp())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for Timestamp struct.
// 实现 UnmarshalJSON 接口
func (t *Timestamp) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
ts, _ := strconv.ParseInt(value, 10, 64)
c := CreateFromTimestamp(ts)
if c.Error == nil {
*t = Timestamp{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for TimestampMilli struct.
// 实现 MarshalJSON 接口
func (t TimestampMilli) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`%d`, t.TimestampMilli())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimestampMilli struct.
// 实现 UnmarshalJSON 接口
func (t *TimestampMilli) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
ts, _ := strconv.ParseInt(value, 10, 64)
c := CreateFromTimestampMilli(ts)
if c.Error == nil {
*t = TimestampMilli{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface MarshalJSON for TimestampMicro struct.
// 实现 MarshalJSON 接口
func (t TimestampMicro) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`%d`, t.TimestampMicro())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimestampMicro struct.
// 实现 UnmarshalJSON 接口
func (t *TimestampMicro) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
ts, _ := strconv.ParseInt(value, 10, 64)
c := CreateFromTimestampMicro(ts)
if c.Error == nil {
*t = TimestampMicro{Carbon: c}
}
return c.Error
}
// MarshalJSON implements the interface json.Marshal for TimestampNano struct.
// 实现 MarshalJSON 接口
func (t TimestampNano) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`%d`, t.TimestampNano())), nil
}
// UnmarshalJSON implements the interface json.Unmarshal for TimestampNano struct.
// 实现 UnmarshalJSON 接口
func (t *TimestampNano) UnmarshalJSON(b []byte) error {
value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
if value == "" || value == "null" {
return nil
}
ts, _ := strconv.ParseInt(value, 10, 64)
c := CreateFromTimestampNano(ts)
if c.Error == nil {
*t = TimestampNano{Carbon: c}
}
return c.Error
}
// Int64 outputs timestamp with second.
// 输出秒级时间戳
func (t Timestamp) Int64() int64 {
return t.Timestamp()
}
// Int64 outputs timestamp with millisecond.
// 输出豪秒级时间戳
func (t TimestampMilli) Int64() int64 {
return t.TimestampMilli()
}
// Int64 outputs timestamp with microsecond.
// 输出微秒级时间戳
func (t TimestampMicro) Int64() int64 {
return t.TimestampMicro()
}
// Int64 outputs timestamp with nanosecond.
// 输出纳秒级时间戳
func (t TimestampNano) Int64() int64 {
return t.TimestampNano()
}
// String implements the interface Stringer for DateTime struct.
// 实现 Stringer 接口
func (t DateTime) String() string {
return t.ToDateTimeString()
}
// String implements the interface Stringer for DateTimeMilli struct.
// 实现 Stringer 接口
func (t DateTimeMilli) String() string {
return t.ToDateTimeMilliString()
}
// String implements the interface Stringer for DateTimeMicro struct.
// 实现 Stringer 接口
func (t DateTimeMicro) String() string {
return t.ToDateTimeMicroString()
}
// String implements the interface Stringer for DateTimeNano struct.
// 实现 Stringer 接口
func (t DateTimeNano) String() string {
return t.ToDateTimeNanoString()
}
// String implements the interface Stringer for Date struct.
// 实现 Stringer 接口
func (t Date) String() string {
return t.ToDateString()
}
// String implements the interface Stringer for DateMilli struct.
// 实现 Stringer 接口
func (t DateMilli) String() string {
return t.ToDateMilliString()
}
// String implements the interface Stringer for DateMicro struct.
// 实现 Stringer 接口
func (t DateMicro) String() string {
return t.ToDateMicroString()
}
// String implements the interface Stringer for DateNano struct.
// 实现 Stringer 接口
func (t DateNano) String() string {
return t.ToDateNanoString()
}
// String implements the interface Stringer for Time struct.
// 实现 Stringer 接口
func (t Time) String() string {
return t.ToTimeString()
}
// String implements the interface Stringer for TimeMilli struct.
// 实现 Stringer 接口
func (t TimeMilli) String() string {
return t.ToTimeMilliString()
}
// String implements the interface Stringer for TimeMicro struct.
// 实现 Stringer 接口
func (t TimeMicro) String() string {
return t.ToTimeMicroString()
}
// String implements the interface Stringer for TimeNano struct.
// 实现 Stringer 接口
func (t TimeNano) String() string {
return t.ToTimeNanoString()
}
// String implements the interface Stringer for Timestamp struct.
// 实现 Stringer 接口
func (t Timestamp) String() string {
return strconv.FormatInt(t.Timestamp(), 10)
}
// String implements the interface Stringer for TimestampMilli struct.
// 实现 Stringer 接口
func (t TimestampMilli) String() string {
return strconv.FormatInt(t.TimestampMilli(), 10)
}
// String implements the interface Stringer for TimestampMicro struct.
// 实现 Stringer 接口
func (t TimestampMicro) String() string {
return strconv.FormatInt(t.TimestampMicro(), 10)
}
// String implements the interface Stringer for TimestampNano struct.
// 实现 Stringer 接口
func (t TimestampNano) String() string {
return strconv.FormatInt(t.TimestampNano(), 10)
}
// ToDateTimeStruct converts Carbon to DateTime.
// 将 Carbon 结构体转换成 DateTime 结构体
func (c Carbon) ToDateTimeStruct() DateTime {
return DateTime{Carbon: c}
}
// ToDateTimeMilliStruct converts Carbon to DateTimeMilli.
// 将 Carbon 结构体转换成 DateTimeMilli 结构体
func (c Carbon) ToDateTimeMilliStruct() DateTimeMilli {
return DateTimeMilli{Carbon: c}
}
// ToDateTimeMicroStruct converts Carbon to DateTimeMicro.
// 将 Carbon 结构体转换成 DateTimeMicro 结构体
func (c Carbon) ToDateTimeMicroStruct() DateTimeMicro {
return DateTimeMicro{Carbon: c}
}
// ToDateTimeNanoStruct converts Carbon to DateTimeNano.
// 将 Carbon 结构体转换成 DateTimeNano 结构体
func (c Carbon) ToDateTimeNanoStruct() DateTimeNano {
return DateTimeNano{Carbon: c}
}
// ToDateStruct converts Carbon to Date.
// 将 Carbon 结构体转换成 Date 结构体
func (c Carbon) ToDateStruct() Date {
return Date{Carbon: c}
}
// ToDateMilliStruct converts Carbon to DateMilli.
// 将 Carbon 结构体转换成 DateMilli 结构体
func (c Carbon) ToDateMilliStruct() DateMilli {
return DateMilli{Carbon: c}
}
// ToDateMicroStruct converts Carbon to DateMicro.
// 将 Carbon 结构体转换成 DateMicro 结构体
func (c Carbon) ToDateMicroStruct() DateMicro {
return DateMicro{Carbon: c}
}
// ToDateNanoStruct converts Carbon to DateNano.
// 将 Carbon 结构体转换成 DateNano 结构体
func (c Carbon) ToDateNanoStruct() DateNano {
return DateNano{Carbon: c}
}
// ToTimeStruct converts Carbon to Time.
// 将 Carbon 结构体转换成 Time 结构体
func (c Carbon) ToTimeStruct() Time {
return Time{Carbon: c}
}
// ToTimeMilliStruct converts Carbon to TimeMilli.
// 将 Carbon 结构体转换成 TimeMilli 结构体
func (c Carbon) ToTimeMilliStruct() TimeMilli {
return TimeMilli{Carbon: c}
}
// ToTimeMicroStruct converts Carbon to TimeMicro.
// 将 Carbon 结构体转换成 TimeMicro 结构体
func (c Carbon) ToTimeMicroStruct() TimeMicro {
return TimeMicro{Carbon: c}
}
// ToTimeNanoStruct converts Carbon to TimeNano.
// 将 Carbon 结构体转换成 TimeNano 结构体
func (c Carbon) ToTimeNanoStruct() TimeNano {
return TimeNano{Carbon: c}
}
// ToTimestampStruct converts Carbon to Timestamp.
// 将 Carbon 结构体转换成 Timestamp 结构体
func (c Carbon) ToTimestampStruct() Timestamp {
return Timestamp{Carbon: c}
}
// ToTimestampMilliStruct converts Carbon to TimestampMilli.
// 将 Carbon 结构体转换成 TimestampMilli 结构体
func (c Carbon) ToTimestampMilliStruct() TimestampMilli {
return TimestampMilli{Carbon: c}
}
// ToTimestampMicroStruct converts Carbon to TimestampMicro.
// 将 Carbon 结构体转换成 TimestampMicro 结构体
func (c Carbon) ToTimestampMicroStruct() TimestampMicro {
return TimestampMicro{Carbon: c}
}
// ToTimestampNanoStruct converts Carbon to TimestampNano.
// 将 Carbon 结构体转换成 TimestampNano 结构体
func (c Carbon) ToTimestampNanoStruct() TimestampNano {
return TimestampNano{Carbon: c}
}