@@ -320,10 +320,6 @@ class BusinessDay(BusinessMixin, SingleConstructorOffset):
320
320
_prefix = "B"
321
321
_attributes = frozenset (["n" , "normalize" , "offset" ])
322
322
323
- def __init__ (self , n = 1 , normalize = False , offset = timedelta (0 )):
324
- BaseOffset .__init__ (self , n , normalize )
325
- object .__setattr__ (self , "_offset" , offset )
326
-
327
323
def _offset_str (self ) -> str :
328
324
def get_str (td ):
329
325
off_str = ""
@@ -423,7 +419,15 @@ def is_on_offset(self, dt: datetime) -> bool:
423
419
return dt .weekday () < 5
424
420
425
421
426
- class BusinessHourMixin (liboffsets .BusinessHourMixin ):
422
+ class BusinessHour (SingleConstructorMixin , liboffsets .BusinessHourMixin ):
423
+ """
424
+ DateOffset subclass representing possibly n business hours.
425
+ """
426
+
427
+ _prefix = "BH"
428
+ _anchor = 0
429
+ _attributes = frozenset (["n" , "normalize" , "start" , "end" , "offset" ])
430
+
427
431
@cache_readonly
428
432
def next_bday (self ):
429
433
"""
@@ -683,22 +687,6 @@ def _is_on_offset(self, dt):
683
687
return False
684
688
685
689
686
- class BusinessHour (BusinessHourMixin , SingleConstructorOffset ):
687
- """
688
- DateOffset subclass representing possibly n business hours.
689
- """
690
-
691
- _prefix = "BH"
692
- _anchor = 0
693
- _attributes = frozenset (["n" , "normalize" , "start" , "end" , "offset" ])
694
-
695
- def __init__ (
696
- self , n = 1 , normalize = False , start = "09:00" , end = "17:00" , offset = timedelta (0 )
697
- ):
698
- BaseOffset .__init__ (self , n , normalize )
699
- super ().__init__ (start = start , end = end , offset = offset )
700
-
701
-
702
690
class CustomBusinessDay (CustomMixin , BusinessDay ):
703
691
"""
704
692
DateOffset subclass representing custom business days excluding holidays.
@@ -731,9 +719,7 @@ def __init__(
731
719
calendar = None ,
732
720
offset = timedelta (0 ),
733
721
):
734
- BaseOffset .__init__ (self , n , normalize )
735
- object .__setattr__ (self , "_offset" , offset )
736
-
722
+ BusinessDay .__init__ (self , n , normalize , offset )
737
723
CustomMixin .__init__ (self , weekmask , holidays , calendar )
738
724
739
725
@apply_wraps
@@ -776,7 +762,7 @@ def is_on_offset(self, dt: datetime) -> bool:
776
762
return np .is_busday (day64 , busdaycal = self .calendar )
777
763
778
764
779
- class CustomBusinessHour (CustomMixin , BusinessHourMixin , SingleConstructorOffset ):
765
+ class CustomBusinessHour (CustomMixin , BusinessHour ):
780
766
"""
781
767
DateOffset subclass representing possibly n custom business days.
782
768
"""
@@ -798,11 +784,8 @@ def __init__(
798
784
end = "17:00" ,
799
785
offset = timedelta (0 ),
800
786
):
801
- BaseOffset .__init__ (self , n , normalize )
802
- object .__setattr__ (self , "_offset" , offset )
803
-
787
+ BusinessHour .__init__ (self , n , normalize , start = start , end = end , offset = offset )
804
788
CustomMixin .__init__ (self , weekmask , holidays , calendar )
805
- BusinessHourMixin .__init__ (self , start = start , end = end , offset = offset )
806
789
807
790
808
791
# ---------------------------------------------------------------------
@@ -902,9 +885,7 @@ def __init__(
902
885
calendar = None ,
903
886
offset = timedelta (0 ),
904
887
):
905
- BaseOffset .__init__ (self , n , normalize )
906
- object .__setattr__ (self , "_offset" , offset )
907
-
888
+ BusinessMixin .__init__ (self , n , normalize , offset )
908
889
CustomMixin .__init__ (self , weekmask , holidays , calendar )
909
890
910
891
@cache_readonly
@@ -984,9 +965,9 @@ def __init__(self, n=1, normalize=False, day_of_month=None):
984
965
BaseOffset .__init__ (self , n , normalize )
985
966
986
967
if day_of_month is None :
987
- object . __setattr__ ( self , " day_of_month" , self ._default_day_of_month )
988
- else :
989
- object .__setattr__ (self , "day_of_month" , int (day_of_month ))
968
+ day_of_month = self ._default_day_of_month
969
+
970
+ object .__setattr__ (self , "day_of_month" , int (day_of_month ))
990
971
if not self ._min_day_of_month <= self .day_of_month <= 27 :
991
972
raise ValueError (
992
973
"day_of_month must be "
0 commit comments