@@ -58,7 +58,7 @@ const MAX_SEQ_LENGTH: u8 = 8;
58
58
///
59
59
/// assert_eq!(jtd_fuzz::fuzz(&schema, &mut rng), json!({
60
60
/// "name": "e",
61
- /// "createdAt": "1931-10-18T14:26:10-05:14 ",
61
+ /// "createdAt": "1931-10-18T15:44:45-03:55 ",
62
62
/// "favoriteNumbers": [166, 142]
63
63
/// }));
64
64
/// ```
@@ -161,9 +161,6 @@ fn fuzz_with_root<R: rand::Rng>(root: &jtd::Schema, rng: &mut R, schema: &jtd::S
161
161
jtd:: form:: TypeValue :: Timestamp => {
162
162
use chrono:: TimeZone ;
163
163
164
- // For timestamp generation, we're going to be real
165
- // psychotic.
166
- //
167
164
// We'll generate timestamps with some random seconds offset
168
165
// from UTC. Most of these random offsets will never have
169
166
// been used historically, but they can nonetheless be used
@@ -172,7 +169,17 @@ fn fuzz_with_root<R: rand::Rng>(root: &jtd::Schema, rng: &mut R, schema: &jtd::S
172
169
// Although timestamp_millis accepts an i64, not all values
173
170
// in that range are permissible. The i32 range is entirely
174
171
// safe.
175
- chrono:: FixedOffset :: east ( rng. gen_range ( -86_400 + 1 , 86_400 - 1 ) )
172
+ //
173
+ // Java's java.time.ZoneOffset restricts offsets to no more
174
+ // than 18 hours from UTC:
175
+ //
176
+ // https://docs.oracle.com/javase/8/docs/api/java/time/ZoneOffset.html
177
+ //
178
+ // To make jtd-fuzz work out of the box with the Java
179
+ // ecosystem, we will limit ourselves to the same range of
180
+ // offsets.
181
+ let max_offset = 18 * 60 * 60 ;
182
+ chrono:: FixedOffset :: east ( rng. gen_range ( -max_offset, max_offset) )
176
183
. timestamp ( rng. gen :: < i32 > ( ) as i64 , 0 )
177
184
. to_rfc3339 ( )
178
185
. into ( )
0 commit comments