@@ -185,8 +185,8 @@ impl FromCqlVal<CqlValue> for NaiveDate {
185
185
}
186
186
}
187
187
188
- #[ cfg( feature = "time" ) ]
189
- impl FromCqlVal < CqlValue > for time :: Date {
188
+ #[ cfg( feature = "time-03 " ) ]
189
+ impl FromCqlVal < CqlValue > for time_03 :: Date {
190
190
fn from_cql ( cql_val : CqlValue ) -> Result < Self , FromCqlValError > {
191
191
match cql_val {
192
192
CqlValue :: Date ( cql_date) => cql_date. try_into ( ) . map_err ( |_| FromCqlValError :: BadVal ) ,
@@ -205,8 +205,8 @@ impl FromCqlVal<CqlValue> for NaiveTime {
205
205
}
206
206
}
207
207
208
- #[ cfg( feature = "time" ) ]
209
- impl FromCqlVal < CqlValue > for time :: Time {
208
+ #[ cfg( feature = "time-03 " ) ]
209
+ impl FromCqlVal < CqlValue > for time_03 :: Time {
210
210
fn from_cql ( cql_val : CqlValue ) -> Result < Self , FromCqlValError > {
211
211
match cql_val {
212
212
CqlValue :: Time ( cql_time) => cql_time. try_into ( ) . map_err ( |_| FromCqlValError :: BadVal ) ,
@@ -226,8 +226,8 @@ impl FromCqlVal<CqlValue> for DateTime<Utc> {
226
226
}
227
227
}
228
228
229
- #[ cfg( feature = "time" ) ]
230
- impl FromCqlVal < CqlValue > for time :: OffsetDateTime {
229
+ #[ cfg( feature = "time-03 " ) ]
230
+ impl FromCqlVal < CqlValue > for time_03 :: OffsetDateTime {
231
231
fn from_cql ( cql_val : CqlValue ) -> Result < Self , FromCqlValError > {
232
232
cql_val
233
233
. as_cql_timestamp ( )
@@ -565,43 +565,49 @@ mod tests {
565
565
assert_eq ! ( Ok ( CqlDate ( u32 :: MAX ) ) , CqlDate :: from_cql( max_date) ) ;
566
566
}
567
567
568
- #[ cfg( feature = "time" ) ]
568
+ #[ cfg( feature = "time-03 " ) ]
569
569
#[ test]
570
- fn date_from_cql ( ) {
570
+ fn date_03_from_cql ( ) {
571
571
// UNIX epoch
572
572
let unix_epoch = CqlValue :: Date ( CqlDate ( 1 << 31 ) ) ;
573
573
assert_eq ! (
574
- Ok ( time :: Date :: from_ordinal_date( 1970 , 1 ) . unwrap( ) ) ,
575
- time :: Date :: from_cql( unix_epoch)
574
+ Ok ( time_03 :: Date :: from_ordinal_date( 1970 , 1 ) . unwrap( ) ) ,
575
+ time_03 :: Date :: from_cql( unix_epoch)
576
576
) ;
577
577
578
578
// 7 days after UNIX epoch
579
579
let after_epoch = CqlValue :: Date ( CqlDate ( ( 1 << 31 ) + 7 ) ) ;
580
580
assert_eq ! (
581
- Ok ( time :: Date :: from_ordinal_date( 1970 , 8 ) . unwrap( ) ) ,
582
- time :: Date :: from_cql( after_epoch)
581
+ Ok ( time_03 :: Date :: from_ordinal_date( 1970 , 8 ) . unwrap( ) ) ,
582
+ time_03 :: Date :: from_cql( after_epoch)
583
583
) ;
584
584
585
585
// 3 days before UNIX epoch
586
586
let before_epoch = CqlValue :: Date ( CqlDate ( ( 1 << 31 ) - 3 ) ) ;
587
587
assert_eq ! (
588
- Ok ( time :: Date :: from_ordinal_date( 1969 , 363 ) . unwrap( ) ) ,
589
- time :: Date :: from_cql( before_epoch)
588
+ Ok ( time_03 :: Date :: from_ordinal_date( 1969 , 363 ) . unwrap( ) ) ,
589
+ time_03 :: Date :: from_cql( before_epoch)
590
590
) ;
591
591
592
- // Min possible stored date. Since value is out of `time ::Date` range, it should return `BadVal` error
592
+ // Min possible stored date. Since value is out of `time_03 ::Date` range, it should return `BadVal` error
593
593
let min_date = CqlValue :: Date ( CqlDate ( u32:: MIN ) ) ;
594
- assert_eq ! ( Err ( FromCqlValError :: BadVal ) , time:: Date :: from_cql( min_date) ) ;
594
+ assert_eq ! (
595
+ Err ( FromCqlValError :: BadVal ) ,
596
+ time_03:: Date :: from_cql( min_date)
597
+ ) ;
595
598
596
- // Max possible stored date. Since value is out of `time ::Date` range, it should return `BadVal` error
599
+ // Max possible stored date. Since value is out of `time_03 ::Date` range, it should return `BadVal` error
597
600
let max_date = CqlValue :: Date ( CqlDate ( u32:: MAX ) ) ;
598
- assert_eq ! ( Err ( FromCqlValError :: BadVal ) , time:: Date :: from_cql( max_date) ) ;
601
+ assert_eq ! (
602
+ Err ( FromCqlValError :: BadVal ) ,
603
+ time_03:: Date :: from_cql( max_date)
604
+ ) ;
599
605
600
- // Different CQL type. Since value can't be casted , it should return `BadCqlType` error
606
+ // Different CQL type. Since value can't be cast , it should return `BadCqlType` error
601
607
let bad_type = CqlValue :: Double ( 0.5 ) ;
602
608
assert_eq ! (
603
609
Err ( FromCqlValError :: BadCqlType ) ,
604
- time :: Date :: from_cql( bad_type)
610
+ time_03 :: Date :: from_cql( bad_type)
605
611
) ;
606
612
}
607
613
@@ -658,56 +664,59 @@ mod tests {
658
664
let bad_time2 = CqlValue :: Time ( CqlTime ( i64:: MAX ) ) ;
659
665
assert_eq ! ( Err ( FromCqlValError :: BadVal ) , NaiveTime :: from_cql( bad_time2) ) ;
660
666
661
- // Different CQL type. Since value can't be casted , it should return `BadCqlType` error
667
+ // Different CQL type. Since value can't be cast , it should return `BadCqlType` error
662
668
let bad_type = CqlValue :: Double ( 0.5 ) ;
663
669
assert_eq ! (
664
670
Err ( FromCqlValError :: BadCqlType ) ,
665
671
NaiveTime :: from_cql( bad_type)
666
672
) ;
667
673
}
668
674
669
- #[ cfg( feature = "time" ) ]
675
+ #[ cfg( feature = "time-03 " ) ]
670
676
#[ test]
671
- fn time_from_cql ( ) {
677
+ fn time_03_from_cql ( ) {
672
678
// Midnight
673
679
let midnight = CqlValue :: Time ( CqlTime ( 0 ) ) ;
674
- assert_eq ! ( Ok ( time:: Time :: MIDNIGHT ) , time:: Time :: from_cql( midnight) ) ;
680
+ assert_eq ! (
681
+ Ok ( time_03:: Time :: MIDNIGHT ) ,
682
+ time_03:: Time :: from_cql( midnight)
683
+ ) ;
675
684
676
685
// 7:15:21.123456789
677
686
let morning = CqlValue :: Time ( CqlTime (
678
687
( 7 * 3600 + 15 * 60 + 21 ) * 1_000_000_000 + 123_456_789 ,
679
688
) ) ;
680
689
assert_eq ! (
681
- Ok ( time :: Time :: from_hms_nano( 7 , 15 , 21 , 123_456_789 ) . unwrap( ) ) ,
682
- time :: Time :: from_cql( morning)
690
+ Ok ( time_03 :: Time :: from_hms_nano( 7 , 15 , 21 , 123_456_789 ) . unwrap( ) ) ,
691
+ time_03 :: Time :: from_cql( morning)
683
692
) ;
684
693
685
694
// 23:59:59.999999999
686
695
let late_night = CqlValue :: Time ( CqlTime (
687
696
( 23 * 3600 + 59 * 60 + 59 ) * 1_000_000_000 + 999_999_999 ,
688
697
) ) ;
689
698
assert_eq ! (
690
- Ok ( time :: Time :: from_hms_nano( 23 , 59 , 59 , 999_999_999 ) . unwrap( ) ) ,
691
- time :: Time :: from_cql( late_night)
699
+ Ok ( time_03 :: Time :: from_hms_nano( 23 , 59 , 59 , 999_999_999 ) . unwrap( ) ) ,
700
+ time_03 :: Time :: from_cql( late_night)
692
701
) ;
693
702
694
- // Bad values. Since value is out of `time ::Time` range, it should return `BadVal` error
703
+ // Bad values. Since value is out of `time_03 ::Time` range, it should return `BadVal` error
695
704
let bad_time1 = CqlValue :: Time ( CqlTime ( -1 ) ) ;
696
705
assert_eq ! (
697
706
Err ( FromCqlValError :: BadVal ) ,
698
- time :: Time :: from_cql( bad_time1)
707
+ time_03 :: Time :: from_cql( bad_time1)
699
708
) ;
700
709
let bad_time2 = CqlValue :: Time ( CqlTime ( i64:: MAX ) ) ;
701
710
assert_eq ! (
702
711
Err ( FromCqlValError :: BadVal ) ,
703
- time :: Time :: from_cql( bad_time2)
712
+ time_03 :: Time :: from_cql( bad_time2)
704
713
) ;
705
714
706
- // Different CQL type. Since value can't be casted , it should return `BadCqlType` error
715
+ // Different CQL type. Since value can't be cast , it should return `BadCqlType` error
707
716
let bad_type = CqlValue :: Double ( 0.5 ) ;
708
717
assert_eq ! (
709
718
Err ( FromCqlValError :: BadCqlType ) ,
710
- time :: Time :: from_cql( bad_type)
719
+ time_03 :: Time :: from_cql( bad_type)
711
720
) ;
712
721
}
713
722
@@ -741,55 +750,55 @@ mod tests {
741
750
) ;
742
751
}
743
752
744
- #[ cfg( feature = "time" ) ]
753
+ #[ cfg( feature = "time-03 " ) ]
745
754
#[ test]
746
- fn offset_datetime_from_cql ( ) {
755
+ fn offset_datetime_03_from_cql ( ) {
747
756
// UNIX epoch
748
757
let unix_epoch = CqlValue :: Timestamp ( CqlTimestamp ( 0 ) ) ;
749
758
assert_eq ! (
750
- Ok ( time :: OffsetDateTime :: UNIX_EPOCH ) ,
751
- time :: OffsetDateTime :: from_cql( unix_epoch)
759
+ Ok ( time_03 :: OffsetDateTime :: UNIX_EPOCH ) ,
760
+ time_03 :: OffsetDateTime :: from_cql( unix_epoch)
752
761
) ;
753
762
754
763
// 1 day 2 hours 3 minutes 4 seconds and 5 nanoseconds before UNIX epoch
755
764
let before_epoch = CqlValue :: Timestamp ( CqlTimestamp ( -( 26 * 3600 + 3 * 60 + 4 ) * 1000 - 5 ) ) ;
756
765
assert_eq ! (
757
- Ok ( time :: OffsetDateTime :: UNIX_EPOCH
758
- - time :: Duration :: new( 26 * 3600 + 3 * 60 + 4 , 5 * 1_000_000 ) ) ,
759
- time :: OffsetDateTime :: from_cql( before_epoch)
766
+ Ok ( time_03 :: OffsetDateTime :: UNIX_EPOCH
767
+ - time_03 :: Duration :: new( 26 * 3600 + 3 * 60 + 4 , 5 * 1_000_000 ) ) ,
768
+ time_03 :: OffsetDateTime :: from_cql( before_epoch)
760
769
) ;
761
770
762
771
// 6 days 7 hours 8 minutes 9 seconds and 10 nanoseconds after UNIX epoch
763
772
let after_epoch =
764
773
CqlValue :: Timestamp ( CqlTimestamp ( ( ( 6 * 24 + 7 ) * 3600 + 8 * 60 + 9 ) * 1000 + 10 ) ) ;
765
774
assert_eq ! (
766
- Ok ( time :: PrimitiveDateTime :: new(
767
- time :: Date :: from_ordinal_date( 1970 , 7 ) . unwrap( ) ,
768
- time :: Time :: from_hms_milli( 7 , 8 , 9 , 10 ) . unwrap( )
775
+ Ok ( time_03 :: PrimitiveDateTime :: new(
776
+ time_03 :: Date :: from_ordinal_date( 1970 , 7 ) . unwrap( ) ,
777
+ time_03 :: Time :: from_hms_milli( 7 , 8 , 9 , 10 ) . unwrap( )
769
778
)
770
779
. assume_utc( ) ) ,
771
- time :: OffsetDateTime :: from_cql( after_epoch)
780
+ time_03 :: OffsetDateTime :: from_cql( after_epoch)
772
781
) ;
773
782
774
- // Min possible stored timestamp. Since value is out of `time ::OffsetDateTime` range, it should return `BadVal` error
783
+ // Min possible stored timestamp. Since value is out of `time_03 ::OffsetDateTime` range, it should return `BadVal` error
775
784
let min_timestamp = CqlValue :: Timestamp ( CqlTimestamp ( i64:: MIN ) ) ;
776
785
assert_eq ! (
777
786
Err ( FromCqlValError :: BadVal ) ,
778
- time :: OffsetDateTime :: from_cql( min_timestamp)
787
+ time_03 :: OffsetDateTime :: from_cql( min_timestamp)
779
788
) ;
780
789
781
- // Max possible stored timestamp. Since value is out of `time ::OffsetDateTime` range, it should return `BadVal` error
790
+ // Max possible stored timestamp. Since value is out of `time_03 ::OffsetDateTime` range, it should return `BadVal` error
782
791
let max_timestamp = CqlValue :: Timestamp ( CqlTimestamp ( i64:: MAX ) ) ;
783
792
assert_eq ! (
784
793
Err ( FromCqlValError :: BadVal ) ,
785
- time :: OffsetDateTime :: from_cql( max_timestamp)
794
+ time_03 :: OffsetDateTime :: from_cql( max_timestamp)
786
795
) ;
787
796
788
- // Different CQL type. Since value can't be casted , it should return `BadCqlType` error
797
+ // Different CQL type. Since value can't be cast , it should return `BadCqlType` error
789
798
let bad_type = CqlValue :: Double ( 0.5 ) ;
790
799
assert_eq ! (
791
800
Err ( FromCqlValError :: BadCqlType ) ,
792
- time :: OffsetDateTime :: from_cql( bad_type)
801
+ time_03 :: OffsetDateTime :: from_cql( bad_type)
793
802
) ;
794
803
}
795
804
0 commit comments