1919from .tz import Timezone , UTC , FixedTimezone , local_timezone
2020from .tz .timezone_info import TimezoneInfo
2121from ._compat import PY33 , basestring
22+ from .constants import (
23+ SUNDAY , MONDAY , TUESDAY , WEDNESDAY ,
24+ THURSDAY , FRIDAY , SATURDAY ,
25+ YEARS_PER_CENTURY , YEARS_PER_DECADE ,
26+ MONTHS_PER_YEAR , DAYS_PER_WEEK ,
27+ MINUTES_PER_HOUR , SECONDS_PER_MINUTE
28+ )
2229
2330
2431class Pendulum (datetime .datetime , TranslatableMixin ):
2532
26- # The day constants
27- SUNDAY = 0
28- MONDAY = 1
29- TUESDAY = 2
30- WEDNESDAY = 3
31- THURSDAY = 4
32- FRIDAY = 5
33- SATURDAY = 6
34-
3533 # Names of days of the week
3634 _days = {
3735 SUNDAY : 'Sunday' ,
@@ -43,16 +41,6 @@ class Pendulum(datetime.datetime, TranslatableMixin):
4341 SATURDAY : 'Saturday'
4442 }
4543
46- # Number of X in Y.
47- YEARS_PER_CENTURY = 100
48- YEARS_PER_DECADE = 10
49- MONTHS_PER_YEAR = 12
50- WEEKS_PER_YEAR = 52
51- DAYS_PER_WEEK = 7
52- HOURS_PER_DAY = 24
53- MINUTES_PER_HOUR = 60
54- SECONDS_PER_MINUTE = 60
55-
5644 # Formats
5745 ATOM = '%Y-%m-%dT%H:%M:%S%_z'
5846 COOKIE = '%A, %d-%b-%Y %H:%M:%S %Z'
@@ -585,7 +573,7 @@ def float_timestamp(self):
585573
586574 @property
587575 def week_of_month (self ):
588- return math .ceil (self .day / self . DAYS_PER_WEEK )
576+ return math .ceil (self .day / DAYS_PER_WEEK )
589577
590578 @property
591579 def age (self ):
@@ -602,8 +590,8 @@ def offset(self):
602590 @property
603591 def offset_hours (self ):
604592 return (self .get_offset ()
605- / self . SECONDS_PER_MINUTE
606- / self . MINUTES_PER_HOUR )
593+ / SECONDS_PER_MINUTE
594+ / MINUTES_PER_HOUR )
607595
608596 @property
609597 def local (self ):
@@ -1351,55 +1339,55 @@ def is_sunday(self):
13511339
13521340 :rtype: bool
13531341 """
1354- return self .day_of_week == self . SUNDAY
1342+ return self .day_of_week == SUNDAY
13551343
13561344 def is_monday (self ):
13571345 """
13581346 Checks if this day is a monday.
13591347
13601348 :rtype: bool
13611349 """
1362- return self .day_of_week == self . MONDAY
1350+ return self .day_of_week == MONDAY
13631351
13641352 def is_tuesday (self ):
13651353 """
13661354 Checks if this day is a tuesday.
13671355
13681356 :rtype: bool
13691357 """
1370- return self .day_of_week == self . TUESDAY
1358+ return self .day_of_week == TUESDAY
13711359
13721360 def is_wednesday (self ):
13731361 """
13741362 Checks if this day is a wednesday.
13751363
13761364 :rtype: bool
13771365 """
1378- return self .day_of_week == self . WEDNESDAY
1366+ return self .day_of_week == WEDNESDAY
13791367
13801368 def is_thursday (self ):
13811369 """
13821370 Checks if this day is a thursday.
13831371
13841372 :rtype: bool
13851373 """
1386- return self .day_of_week == self . THURSDAY
1374+ return self .day_of_week == THURSDAY
13871375
13881376 def is_friday (self ):
13891377 """
13901378 Checks if this day is a friday.
13911379
13921380 :rtype: bool
13931381 """
1394- return self .day_of_week == self . FRIDAY
1382+ return self .day_of_week == FRIDAY
13951383
13961384 def is_saturday (self ):
13971385 """
13981386 Checks if this day is a saturday.
13991387
14001388 :rtype: bool
14011389 """
1402- return self .day_of_week == self . SATURDAY
1390+ return self .day_of_week == SATURDAY
14031391
14041392 def is_birthday (self , dt = None ):
14051393 """
@@ -1743,7 +1731,7 @@ def _start_of_decade(self):
17431731
17441732 :rtype: Pendulum
17451733 """
1746- year = self .year - self .year % self . YEARS_PER_DECADE
1734+ year = self .year - self .year % YEARS_PER_DECADE
17471735 return self .with_date_time (year , 1 , 1 , 0 , 0 , 0 )
17481736
17491737 def _end_of_decade (self ):
@@ -1753,7 +1741,7 @@ def _end_of_decade(self):
17531741
17541742 :rtype: Pendulum
17551743 """
1756- year = self .year - self .year % self . YEARS_PER_DECADE + self . YEARS_PER_DECADE - 1
1744+ year = self .year - self .year % YEARS_PER_DECADE + YEARS_PER_DECADE - 1
17571745
17581746 return self .with_date_time (
17591747 year , 12 , 31 , 23 , 59 , 59 , 999999
@@ -1766,7 +1754,7 @@ def _start_of_century(self):
17661754
17671755 :rtype: Pendulum
17681756 """
1769- year = self .year - 1 - (self .year - 1 ) % self . YEARS_PER_CENTURY + 1
1757+ year = self .year - 1 - (self .year - 1 ) % YEARS_PER_CENTURY + 1
17701758
17711759 return self .with_date_time (year , 1 , 1 , 0 , 0 , 0 )
17721760
@@ -1777,7 +1765,7 @@ def _end_of_century(self):
17771765
17781766 :rtype: Pendulum
17791767 """
1780- year = self .year - 1 - (self .year - 1 ) % self . YEARS_PER_CENTURY + self . YEARS_PER_CENTURY
1768+ year = self .year - 1 - (self .year - 1 ) % YEARS_PER_CENTURY + YEARS_PER_CENTURY
17811769
17821770 return self .with_date_time (
17831771 year , 12 , 31 , 23 , 59 , 59 , 999999
@@ -2084,7 +2072,7 @@ def _last_of_year(self, day_of_week=None):
20842072
20852073 :rtype: Pendulum
20862074 """
2087- return self .month_ (self . MONTHS_PER_YEAR ).last_of ('month' , day_of_week )
2075+ return self .month_ (MONTHS_PER_YEAR ).last_of ('month' , day_of_week )
20882076
20892077 def _nth_of_year (self , nth , day_of_week ):
20902078 """
0 commit comments