File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -136,9 +136,13 @@ pub fn write_timestamp<W: RmpWrite>(wr: &mut W, timestamp: Timestamp) -> Result<
136
136
wr. write_data_u32 ( secs as u32 ) ?;
137
137
} ,
138
138
Timestamp :: T64 ( timedate) => {
139
- let secs = timedate. timestamp ( ) ;
140
- let nsecs = timedate. timestamp_subsec_nanos ( ) ;
141
- if secs < 0 || secs > 0x3_ffff_ffff || nsecs > crate :: MAX_NSECS {
139
+ let mut secs = timedate. timestamp ( ) ;
140
+ let mut nsecs = timedate. timestamp_subsec_nanos ( ) ;
141
+ if nsecs > crate :: MAX_NSECS {
142
+ nsecs %= 1_000_000_000 ;
143
+ secs += 1 ;
144
+ }
145
+ if secs < 0 || secs > 0x3_ffff_ffff {
142
146
return Ok ( false )
143
147
}
144
148
write_marker ( wr, Marker :: FixExt8 ) . map_err ( |e| e. 0 ) ?;
@@ -147,10 +151,11 @@ pub fn write_timestamp<W: RmpWrite>(wr: &mut W, timestamp: Timestamp) -> Result<
147
151
wr. write_data_u64 ( data) ?;
148
152
} ,
149
153
Timestamp :: T96 ( timedate) => {
150
- let secs = timedate. timestamp ( ) ;
151
- let nsecs = timedate. timestamp_subsec_nanos ( ) ;
154
+ let mut secs = timedate. timestamp ( ) ;
155
+ let mut nsecs = timedate. timestamp_subsec_nanos ( ) ;
152
156
if nsecs > crate :: MAX_NSECS {
153
- return Ok ( false )
157
+ nsecs %= 1_000_000_000 ;
158
+ secs += 1 ;
154
159
}
155
160
write_marker ( wr, Marker :: Ext8 ) . map_err ( |e| e. 0 ) ?;
156
161
wr. write_data_u8 ( 12 ) ?;
You can’t perform that action at this time.
0 commit comments