@@ -184,8 +184,9 @@ impl CqlValue {
184
184
}
185
185
}
186
186
187
+ #[ cfg( test) ]
187
188
#[ cfg( feature = "chrono-04" ) ]
188
- pub fn as_naive_date ( & self ) -> Option < chrono_04:: NaiveDate > {
189
+ fn as_naive_date_04 ( & self ) -> Option < chrono_04:: NaiveDate > {
189
190
self . as_cql_date ( ) . and_then ( |date| date. try_into ( ) . ok ( ) )
190
191
}
191
192
@@ -202,8 +203,9 @@ impl CqlValue {
202
203
}
203
204
}
204
205
206
+ #[ cfg( test) ]
205
207
#[ cfg( feature = "chrono-04" ) ]
206
- pub fn as_datetime ( & self ) -> Option < chrono_04:: DateTime < chrono_04:: Utc > > {
208
+ fn as_datetime_04 ( & self ) -> Option < chrono_04:: DateTime < chrono_04:: Utc > > {
207
209
self . as_cql_timestamp ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
208
210
}
209
211
@@ -220,8 +222,9 @@ impl CqlValue {
220
222
}
221
223
}
222
224
225
+ #[ cfg( test) ]
223
226
#[ cfg( feature = "chrono-04" ) ]
224
- pub fn as_naive_time ( & self ) -> Option < chrono_04:: NaiveTime > {
227
+ fn as_naive_time_04 ( & self ) -> Option < chrono_04:: NaiveTime > {
225
228
self . as_cql_time ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
226
229
}
227
230
@@ -1280,7 +1283,7 @@ mod tests {
1280
1283
super :: deser_cql_value ( & ColumnType :: Date , & mut ( 1u32 << 31 ) . to_be_bytes ( ) . as_ref ( ) )
1281
1284
. unwrap ( ) ;
1282
1285
1283
- assert_eq ! ( date. as_naive_date ( ) , Some ( unix_epoch) ) ;
1286
+ assert_eq ! ( date. as_naive_date_04 ( ) , Some ( unix_epoch) ) ;
1284
1287
1285
1288
// 2^31 - 30 when converted to NaiveDate is 1969-12-02
1286
1289
let before_epoch = NaiveDate :: from_ymd_opt ( 1969 , 12 , 2 ) . unwrap ( ) ;
@@ -1290,7 +1293,7 @@ mod tests {
1290
1293
)
1291
1294
. unwrap ( ) ;
1292
1295
1293
- assert_eq ! ( date. as_naive_date ( ) , Some ( before_epoch) ) ;
1296
+ assert_eq ! ( date. as_naive_date_04 ( ) , Some ( before_epoch) ) ;
1294
1297
1295
1298
// 2^31 + 30 when converted to NaiveDate is 1970-01-31
1296
1299
let after_epoch = NaiveDate :: from_ymd_opt ( 1970 , 1 , 31 ) . unwrap ( ) ;
@@ -1300,20 +1303,20 @@ mod tests {
1300
1303
)
1301
1304
. unwrap ( ) ;
1302
1305
1303
- assert_eq ! ( date. as_naive_date ( ) , Some ( after_epoch) ) ;
1306
+ assert_eq ! ( date. as_naive_date_04 ( ) , Some ( after_epoch) ) ;
1304
1307
1305
1308
// 0 and u32::MAX are out of NaiveDate range, fails with an error, not panics
1306
1309
assert_eq ! (
1307
1310
super :: deser_cql_value( & ColumnType :: Date , & mut 0_u32 . to_be_bytes( ) . as_ref( ) )
1308
1311
. unwrap( )
1309
- . as_naive_date ( ) ,
1312
+ . as_naive_date_04 ( ) ,
1310
1313
None
1311
1314
) ;
1312
1315
1313
1316
assert_eq ! (
1314
1317
super :: deser_cql_value( & ColumnType :: Date , & mut u32 :: MAX . to_be_bytes( ) . as_ref( ) )
1315
1318
. unwrap( )
1316
- . as_naive_date ( ) ,
1319
+ . as_naive_date_04 ( ) ,
1317
1320
None
1318
1321
) ;
1319
1322
}
@@ -1402,7 +1405,7 @@ mod tests {
1402
1405
let time =
1403
1406
super :: deser_cql_value ( & ColumnType :: Time , & mut ( 0i64 ) . to_be_bytes ( ) . as_ref ( ) ) . unwrap ( ) ;
1404
1407
1405
- assert_eq ! ( time. as_naive_time ( ) , Some ( midnight) ) ;
1408
+ assert_eq ! ( time. as_naive_time_04 ( ) , Some ( midnight) ) ;
1406
1409
1407
1410
// 10:10:30.500,000,001
1408
1411
let ( h, m, s, n) = ( 10 , 10 , 30 , 500_000_001 ) ;
@@ -1415,7 +1418,7 @@ mod tests {
1415
1418
)
1416
1419
. unwrap ( ) ;
1417
1420
1418
- assert_eq ! ( time. as_naive_time ( ) , Some ( midnight) ) ;
1421
+ assert_eq ! ( time. as_naive_time_04 ( ) , Some ( midnight) ) ;
1419
1422
1420
1423
// 23:59:59.999,999,999
1421
1424
let ( h, m, s, n) = ( 23 , 59 , 59 , 999_999_999 ) ;
@@ -1428,7 +1431,7 @@ mod tests {
1428
1431
)
1429
1432
. unwrap ( ) ;
1430
1433
1431
- assert_eq ! ( time. as_naive_time ( ) , Some ( midnight) ) ;
1434
+ assert_eq ! ( time. as_naive_time_04 ( ) , Some ( midnight) ) ;
1432
1435
}
1433
1436
1434
1437
#[ cfg( feature = "time-03" ) ]
@@ -1493,7 +1496,7 @@ mod tests {
1493
1496
let date = super :: deser_cql_value ( & ColumnType :: Timestamp , & mut 0i64 . to_be_bytes ( ) . as_ref ( ) )
1494
1497
. unwrap ( ) ;
1495
1498
1496
- assert_eq ! ( date. as_datetime ( ) , Some ( unix_epoch) ) ;
1499
+ assert_eq ! ( date. as_datetime_04 ( ) , Some ( unix_epoch) ) ;
1497
1500
1498
1501
// When converted to NaiveDateTime, this is 1969-12-01 11:29:29.5
1499
1502
let timestamp: i64 = -( ( ( ( 30 * 24 + 12 ) * 60 + 30 ) * 60 + 30 ) * 1000 + 500 ) ;
@@ -1508,7 +1511,7 @@ mod tests {
1508
1511
)
1509
1512
. unwrap ( ) ;
1510
1513
1511
- assert_eq ! ( date. as_datetime ( ) , Some ( before_epoch) ) ;
1514
+ assert_eq ! ( date. as_datetime_04 ( ) , Some ( before_epoch) ) ;
1512
1515
1513
1516
// when converted to NaiveDateTime, this is is 1970-01-31 12:30:30.5
1514
1517
let timestamp: i64 = ( ( ( 30 * 24 + 12 ) * 60 + 30 ) * 60 + 30 ) * 1000 + 500 ;
@@ -1523,20 +1526,20 @@ mod tests {
1523
1526
)
1524
1527
. unwrap ( ) ;
1525
1528
1526
- assert_eq ! ( date. as_datetime ( ) , Some ( after_epoch) ) ;
1529
+ assert_eq ! ( date. as_datetime_04 ( ) , Some ( after_epoch) ) ;
1527
1530
1528
1531
// 0 and u32::MAX are out of NaiveDate range, fails with an error, not panics
1529
1532
assert_eq ! (
1530
1533
super :: deser_cql_value( & ColumnType :: Timestamp , & mut i64 :: MIN . to_be_bytes( ) . as_ref( ) )
1531
1534
. unwrap( )
1532
- . as_datetime ( ) ,
1535
+ . as_datetime_04 ( ) ,
1533
1536
None
1534
1537
) ;
1535
1538
1536
1539
assert_eq ! (
1537
1540
super :: deser_cql_value( & ColumnType :: Timestamp , & mut i64 :: MAX . to_be_bytes( ) . as_ref( ) )
1538
1541
. unwrap( )
1539
- . as_datetime ( ) ,
1542
+ . as_datetime_04 ( ) ,
1540
1543
None
1541
1544
) ;
1542
1545
}
0 commit comments