@@ -226,21 +226,33 @@ mod relative {
226
226
let time = gix_date:: parse ( input, Some ( now) ) . expect ( "relative time string should parse to a Time" ) ;
227
227
( input, time)
228
228
} ) ;
229
- assert_eq ! ( with_times. map( |_| Sign :: Plus ) , with_times. map( |( _, time) | time. sign) ) ;
230
- assert_eq ! ( with_times. map( |_| 0 ) , with_times. map( |( _, time) | time. offset) ) ;
229
+ assert_eq ! (
230
+ with_times. map( |( _, time) | time. sign) ,
231
+ with_times. map( |_| Sign :: Plus ) ,
232
+ "Despite being in the past, the dates produced are positive, as they are still post-epoch"
233
+ ) ;
234
+ assert_eq ! (
235
+ with_times. map( |( _, time) | time. offset) ,
236
+ with_times. map( |_| 0 ) ,
237
+ "They don't pick up local time"
238
+ ) ;
231
239
232
240
let with_expected = cases. map ( |( input, span) | {
233
- let expected = Zoned :: try_from ( now)
234
- . expect ( "test needs to convert current time to a timestamp" )
235
- // account for the loss of precision when creating `Time` with seconds
236
- . round (
237
- jiff:: ZonedRound :: new ( )
238
- . smallest ( jiff:: Unit :: Second )
239
- . mode ( jiff:: RoundMode :: Trunc ) ,
240
- )
241
- . expect ( "test needs to truncate current timestamp to seconds" )
242
- . saturating_sub ( span)
243
- . timestamp ( ) ;
241
+ let expected = Zoned :: new (
242
+ now. try_into ( ) . expect ( "system time is representable" ) ,
243
+ // As relative dates are always UTC in Git, we do the same, and must
244
+ // compare to UTC as well or else time might be off due to daylight savings, etc.
245
+ jiff:: tz:: TimeZone :: UTC ,
246
+ )
247
+ // account for the loss of precision when creating `Time` with seconds
248
+ . round (
249
+ jiff:: ZonedRound :: new ( )
250
+ . smallest ( jiff:: Unit :: Second )
251
+ . mode ( jiff:: RoundMode :: Trunc ) ,
252
+ )
253
+ . expect ( "test needs to truncate current timestamp to seconds" )
254
+ . saturating_sub ( span)
255
+ . timestamp ( ) ;
244
256
245
257
( input, expected)
246
258
} ) ;
0 commit comments