@@ -754,6 +754,31 @@ func ExampleTime_Sub() {
754
754
// difference = 12h0m0s
755
755
}
756
756
757
+ func ExampleTime_AppendBinary () {
758
+ t := time .Date (2025 , 4 , 1 , 15 , 30 , 45 , 123456789 , time .UTC )
759
+
760
+ var buffer []byte
761
+ buffer , err := t .AppendBinary (buffer )
762
+ if err != nil {
763
+ panic (err )
764
+ }
765
+
766
+ var parseTime time.Time
767
+ err = parseTime .UnmarshalBinary (buffer [:])
768
+ if err != nil {
769
+ panic (err )
770
+ }
771
+
772
+ fmt .Printf ("t: %v\n " , t )
773
+ fmt .Printf ("parseTime: %v\n " , parseTime )
774
+ fmt .Printf ("equal: %v\n " , parseTime .Equal (t ))
775
+
776
+ // Output:
777
+ // t: 2025-04-01 15:30:45.123456789 +0000 UTC
778
+ // parseTime: 2025-04-01 15:30:45.123456789 +0000 UTC
779
+ // equal: true
780
+ }
781
+
757
782
func ExampleTime_AppendFormat () {
758
783
t := time .Date (2017 , time .November , 4 , 11 , 0 , 0 , 0 , time .UTC )
759
784
text := []byte ("Time: " )
@@ -765,6 +790,21 @@ func ExampleTime_AppendFormat() {
765
790
// Time: 11:00AM
766
791
}
767
792
793
+ func ExampleTime_AppendText () {
794
+ t := time .Date (2025 , 4 , 1 , 15 , 30 , 45 , 123456789 , time .UTC )
795
+
796
+ buffer := []byte ("t: " )
797
+
798
+ buffer , err := t .AppendText (buffer )
799
+ if err != nil {
800
+ panic (err )
801
+ }
802
+
803
+ fmt .Printf ("%s\n " , buffer )
804
+
805
+ // Output:
806
+ // t: 2025-04-01T15:30:45.123456789Z
807
+ }
768
808
func ExampleFixedZone () {
769
809
loc := time .FixedZone ("UTC-8" , - 8 * 60 * 60 )
770
810
t := time .Date (2009 , time .November , 10 , 23 , 0 , 0 , 0 , loc )
0 commit comments