@@ -583,13 +583,21 @@ def __init__(self, start='09:00', end='17:00', offset=timedelta(0)):
583
583
if _iterable_not_string (start ):
584
584
start = np .asarray (start )
585
585
if len (start ) == 0 :
586
+ < << << << HEAD
586
587
raise ValueError ('Must include at least 1 start time' )
588
+ == == == =
589
+ raise ValueError ('number of starting time cannot be 0' )
590
+ >> >> >> > Edit comments and tests
587
591
else :
588
592
start = np .array ([start ])
589
593
if _iterable_not_string (end ):
590
594
end = np .asarray (end )
591
595
if len (end ) == 0 :
596
+ < << << << HEAD
592
597
raise ValueError ('Must include at least 1 end time' )
598
+ == == == =
599
+ raise ValueError ('number of ending time cannot be 0' )
600
+ >> >> >> > Edit comments and tests
593
601
else :
594
602
end = np .array ([end ])
595
603
@@ -645,10 +653,16 @@ def _get_daytime_flag(self, start, end):
645
653
646
654
def _next_opening_time (self , other , sign = 1 ):
647
655
"""
656
+ <<<<<<< HEAD
648
657
If self.n and sign have the same sign, return the earliest opening time
649
658
later than or equal to current time.
650
659
Otherwise the latest opening time earlier than or equal to current
651
660
time.
661
+ =======
662
+ If self.n and dir have the same sign, return the earliest opening time
663
+ later than or equal to current time.
664
+ Otherwise the latest opening time earlier than or equal to current time.
665
+ >>>>>>> Edit comments and tests
652
666
653
667
Opening time always locates on BusinessDay.
654
668
However, closing time may not if business hour extends over midnight.
@@ -657,14 +671,20 @@ def _next_opening_time(self, other, sign=1):
657
671
latest_start = self .start [- 1 ]
658
672
if not self .next_bday .onOffset (other ):
659
673
# today is not business day
674
+ < << << << HEAD
660
675
other = other + sign * self .next_bday
661
676
if self .n * sign >= 0 :
677
+ == == == =
678
+ other = other + dir * self .next_bday
679
+ if self .n * dir >= 0 :
680
+ > >> >> >> Edit comments and tests
662
681
return datetime (other .year , other .month , other .day ,
663
682
earliest_start .hour , earliest_start .minute )
664
683
else :
665
684
return datetime (other .year , other .month , other .day ,
666
685
latest_start .hour , latest_start .minute )
667
686
else :
687
+ << << << < HEAD
668
688
if self .n * sign >= 0 and latest_start < other .time ():
669
689
# current time is after latest starting time in today
670
690
other = other + sign * self .next_bday
@@ -676,6 +696,19 @@ def _next_opening_time(self, other, sign=1):
676
696
return datetime (other .year , other .month , other .day ,
677
697
latest_start .hour , latest_start .minute )
678
698
if self .n * sign >= 0 :
699
+ == == == =
700
+ if self .n * dir >= 0 and latest_start < other .time ():
701
+ # current time is after latest starting time in today
702
+ other = other + dir * self .next_bday
703
+ return datetime (other .year , other .month , other .day ,
704
+ earliest_start .hour , earliest_start .minute )
705
+ elif self .n * dir < 0 and other .time () < earliest_start :
706
+ # current time is before earliest starting time in today
707
+ other = other + dir * self .next_bday
708
+ return datetime (other .year , other .month , other .day ,
709
+ latest_start .hour , latest_start .minute )
710
+ if self .n * dir >= 0 :
711
+ > >> >> >> Edit comments and tests
679
712
# find earliest starting time later than or equal to current time
680
713
for st in self .start :
681
714
if other .time () <= st :
@@ -692,8 +725,12 @@ def _prev_opening_time(self, other):
692
725
"""
693
726
If n is positive, return the latest opening time earlier than or equal
694
727
to current time.
728
+ <<<<<<< HEAD
695
729
Otherwise the earliest opening time later than or equal to current
696
730
time.
731
+ =======
732
+ Otherwise the earliest opening time later than or equal to current time.
733
+ >>>>>>> Edit comments and tests
697
734
698
735
"""
699
736
return self ._next_opening_time (other , sign = - 1 )
0 commit comments