@@ -1511,50 +1511,7 @@ class YearBegin(liboffsets.YearOffset):
1511
1511
# Special Offset Classes
1512
1512
1513
1513
1514
- class FY5253Mixin (SingleConstructorOffset ):
1515
- def __init__ (
1516
- self , n = 1 , normalize = False , weekday = 0 , startingMonth = 1 , variation = "nearest"
1517
- ):
1518
- BaseOffset .__init__ (self , n , normalize )
1519
- object .__setattr__ (self , "startingMonth" , startingMonth )
1520
- object .__setattr__ (self , "weekday" , weekday )
1521
-
1522
- object .__setattr__ (self , "variation" , variation )
1523
-
1524
- if self .n == 0 :
1525
- raise ValueError ("N cannot be 0" )
1526
-
1527
- if self .variation not in ["nearest" , "last" ]:
1528
- raise ValueError (f"{ self .variation } is not a valid variation" )
1529
-
1530
- def is_anchored (self ) -> bool :
1531
- return (
1532
- self .n == 1 and self .startingMonth is not None and self .weekday is not None
1533
- )
1534
-
1535
- # --------------------------------------------------------------------
1536
- # Name-related methods
1537
-
1538
- @property
1539
- def rule_code (self ) -> str :
1540
- prefix = self ._prefix
1541
- suffix = self .get_rule_code_suffix ()
1542
- return f"{ prefix } -{ suffix } "
1543
-
1544
- def _get_suffix_prefix (self ) -> str :
1545
- if self .variation == "nearest" :
1546
- return "N"
1547
- else :
1548
- return "L"
1549
-
1550
- def get_rule_code_suffix (self ) -> str :
1551
- prefix = self ._get_suffix_prefix ()
1552
- month = ccalendar .MONTH_ALIASES [self .startingMonth ]
1553
- weekday = ccalendar .int_to_weekday [self .weekday ]
1554
- return f"{ prefix } -{ month } -{ weekday } "
1555
-
1556
-
1557
- class FY5253 (FY5253Mixin ):
1514
+ class FY5253 (liboffsets .FY5253Mixin ):
1558
1515
"""
1559
1516
Describes 52-53 week fiscal year. This is also known as a 4-4-5 calendar.
1560
1517
@@ -1605,6 +1562,10 @@ class FY5253(FY5253Mixin):
1605
1562
_prefix = "RE"
1606
1563
_attributes = frozenset (["weekday" , "startingMonth" , "variation" ])
1607
1564
1565
+ def __reduce__ (self ):
1566
+ tup = (self .n , self .normalize , self .weekday , self .startingMonth , self .variation )
1567
+ return type (self ), tup
1568
+
1608
1569
def is_on_offset (self , dt : datetime ) -> bool :
1609
1570
if self .normalize and not is_normalized (dt ):
1610
1571
return False
@@ -1722,7 +1683,7 @@ def _from_name(cls, *args):
1722
1683
return cls (** cls ._parse_suffix (* args ))
1723
1684
1724
1685
1725
- class FY5253Quarter (FY5253Mixin ):
1686
+ class FY5253Quarter (liboffsets . FY5253Mixin ):
1726
1687
"""
1727
1688
DateOffset increments between business quarter dates
1728
1689
for 52-53 week fiscal year (also known as a 4-4-5 calendar).
@@ -1792,9 +1753,22 @@ def __init__(
1792
1753
qtr_with_extra_week = 1 ,
1793
1754
variation = "nearest" ,
1794
1755
):
1795
- FY5253Mixin .__init__ (self , n , normalize , weekday , startingMonth , variation )
1756
+ liboffsets .FY5253Mixin .__init__ (
1757
+ self , n , normalize , weekday , startingMonth , variation
1758
+ )
1796
1759
object .__setattr__ (self , "qtr_with_extra_week" , qtr_with_extra_week )
1797
1760
1761
+ def __reduce__ (self ):
1762
+ tup = (
1763
+ self .n ,
1764
+ self .normalize ,
1765
+ self .weekday ,
1766
+ self .startingMonth ,
1767
+ self .qtr_with_extra_week ,
1768
+ self .variation ,
1769
+ )
1770
+ return type (self ), tup
1771
+
1798
1772
@cache_readonly
1799
1773
def _offset (self ):
1800
1774
return FY5253 (
@@ -1918,7 +1892,7 @@ def is_on_offset(self, dt: datetime) -> bool:
1918
1892
1919
1893
@property
1920
1894
def rule_code (self ) -> str :
1921
- suffix = FY5253Mixin .rule_code .fget (self ) # type: ignore
1895
+ suffix = liboffsets . FY5253Mixin .rule_code .__get__ (self )
1922
1896
qtr = self .qtr_with_extra_week
1923
1897
return f"{ suffix } -{ qtr } "
1924
1898
0 commit comments