@@ -634,3 +634,99 @@ def test_to_datetime_format_param(arg, utc, format):
634
634
pd .testing .assert_series_equal (
635
635
bf_result , pd_result , check_index_type = False , check_names = False
636
636
)
637
+
638
+
639
+ @pytest .mark .parametrize (
640
+ ("arg" , "utc" , "output_in_utc" , "format" ),
641
+ [
642
+ (
643
+ ["2014-08-15 08:15:12" , "2011-08-15 08:15:12" , "2015-08-15 08:15:12" ],
644
+ False ,
645
+ False ,
646
+ None ,
647
+ ),
648
+ (
649
+ [
650
+ "2008-12-25 05:30:00Z" ,
651
+ "2008-12-25 05:30:00-00:00" ,
652
+ "2008-12-25 05:30:00+00:00" ,
653
+ "2008-12-25 05:30:00-0000" ,
654
+ "2008-12-25 05:30:00+0000" ,
655
+ "2008-12-25 05:30:00-00" ,
656
+ "2008-12-25 05:30:00+00" ,
657
+ ],
658
+ False ,
659
+ True ,
660
+ None ,
661
+ ),
662
+ (
663
+ ["2014-08-15 08:15:12" , "2011-08-15 08:15:12" , "2015-08-15 08:15:12" ],
664
+ True ,
665
+ True ,
666
+ "%Y-%m-%d %H:%M:%S" ,
667
+ ),
668
+ (
669
+ [
670
+ "2014-08-15 08:15:12+05:00" ,
671
+ "2011-08-15 08:15:12+05:00" ,
672
+ "2015-08-15 08:15:12+05:00" ,
673
+ ],
674
+ True ,
675
+ True ,
676
+ None ,
677
+ ),
678
+ ],
679
+ )
680
+ def test_to_datetime_string_inputs (arg , utc , output_in_utc , format ):
681
+ bf_result = (
682
+ bpd .to_datetime (arg , utc = utc , format = format )
683
+ .to_pandas ()
684
+ .astype ("datetime64[ns, UTC]" if output_in_utc else "datetime64[ns]" )
685
+ )
686
+ pd_result = pd .Series (pd .to_datetime (arg , utc = utc , format = format )).dt .floor ("us" )
687
+ pd .testing .assert_series_equal (
688
+ bf_result , pd_result , check_index_type = False , check_names = False
689
+ )
690
+
691
+
692
+ @pytest .mark .parametrize (
693
+ ("arg" , "utc" , "output_in_utc" ),
694
+ [
695
+ (
696
+ [datetime (2023 , 1 , 1 , 12 , 0 ), datetime (2023 , 2 , 1 , 12 , 0 )],
697
+ False ,
698
+ False ,
699
+ ),
700
+ (
701
+ [datetime (2023 , 1 , 1 , 12 , 0 ), datetime (2023 , 2 , 1 , 12 , 0 )],
702
+ True ,
703
+ True ,
704
+ ),
705
+ (
706
+ [
707
+ datetime (2023 , 1 , 1 , 12 , 0 , tzinfo = pytz .timezone ("UTC" )),
708
+ datetime (2023 , 1 , 1 , 12 , 0 , tzinfo = pytz .timezone ("UTC" )),
709
+ ],
710
+ True ,
711
+ True ,
712
+ ),
713
+ (
714
+ [
715
+ datetime (2023 , 1 , 1 , 12 , 0 , tzinfo = pytz .timezone ("America/New_York" )),
716
+ datetime (2023 , 1 , 1 , 12 , 0 , tzinfo = pytz .timezone ("UTC" )),
717
+ ],
718
+ True ,
719
+ True ,
720
+ ),
721
+ ],
722
+ )
723
+ def test_to_datetime_timestamp_inputs (arg , utc , output_in_utc ):
724
+ bf_result = (
725
+ bpd .to_datetime (arg , utc = utc )
726
+ .to_pandas ()
727
+ .astype ("datetime64[ns, UTC]" if output_in_utc else "datetime64[ns]" )
728
+ )
729
+ pd_result = pd .Series (pd .to_datetime (arg , utc = utc )).dt .floor ("us" )
730
+ pd .testing .assert_series_equal (
731
+ bf_result , pd_result , check_index_type = False , check_names = False
732
+ )
0 commit comments