@@ -222,7 +222,7 @@ def parse(cls, time=None, tz=pytz.UTC):
222222 dt = dateparser .parse (time )
223223
224224 if not dt :
225- raise PendulumException ('Invalid time string "%s"' % time )
225+ raise PendulumException ('Invalid time string "{}"' . format ( time ) )
226226
227227 return cls (
228228 dt .year , dt .month , dt .day ,
@@ -867,7 +867,7 @@ def format_locale(cls, locale):
867867 """
868868 m = re .match ('([a-z]{2})[-_]([a-z]{2})' , locale , re .I )
869869 if m :
870- return '%s_%s' % (m .group (1 ).lower (), m .group (2 ).lower ())
870+ return '{}_{}' . format (m .group (1 ).lower (), m .group (2 ).lower ())
871871 else :
872872 return locale .lower ()
873873
@@ -942,7 +942,7 @@ def _strftime(self, m):
942942 else :
943943 return {1 : 'st' , 2 : 'nd' , 3 : 'rd' }.get (self .day % 10 , "th" )
944944
945- raise ValueError ('Unknown formatter %%%s' % fmt )
945+ raise ValueError ('Unknown formatter %%{}' . format ( fmt ) )
946946
947947 def __str__ (self ):
948948 if self ._to_string_format is None :
@@ -1936,9 +1936,9 @@ def start_of(self, unit):
19361936 :rtype: Pendulum
19371937 """
19381938 if unit not in self ._MODIFIERS_VALID_UNITS :
1939- raise ValueError ('Invalid unit "%s " for start_of()' % unit )
1939+ raise ValueError ('Invalid unit "{} " for start_of()' . format ( unit ) )
19401940
1941- return getattr (self , '_start_of_%s' % unit )()
1941+ return getattr (self , '_start_of_{}' . format ( unit ) )()
19421942
19431943 def end_of (self , unit ):
19441944 """
@@ -2148,9 +2148,9 @@ def first_of(self, unit, day_of_week=None):
21482148 :rtype: Pendulum
21492149 """
21502150 if unit not in ['month' , 'quarter' , 'year' ]:
2151- raise PendulumException ('Invalid unit "%s " for first_of()' % unit )
2151+ raise PendulumException ('Invalid unit "{} " for first_of()' . format ( unit ) )
21522152
2153- return getattr (self , '_first_of_%s' % unit )(day_of_week )
2153+ return getattr (self , '_first_of_{}' . format ( unit ) )(day_of_week )
21542154
21552155 def last_of (self , unit , day_of_week = None ):
21562156 """
@@ -2169,9 +2169,9 @@ def last_of(self, unit, day_of_week=None):
21692169 :rtype: Pendulum
21702170 """
21712171 if unit not in ['month' , 'quarter' , 'year' ]:
2172- raise PendulumException ('Invalid unit "%s " for first_of()' % unit )
2172+ raise PendulumException ('Invalid unit "{} " for first_of()' . format ( unit ) )
21732173
2174- return getattr (self , '_last_of_%s' % unit )(day_of_week )
2174+ return getattr (self , '_last_of_{}' . format ( unit ) )(day_of_week )
21752175
21762176 def nth_of (self , unit , nth , day_of_week ):
21772177 """
@@ -2193,12 +2193,12 @@ def nth_of(self, unit, nth, day_of_week):
21932193 :rtype: Pendulum
21942194 """
21952195 if unit not in ['month' , 'quarter' , 'year' ]:
2196- raise PendulumException ('Invalid unit "%s " for first_of()' % unit )
2196+ raise PendulumException ('Invalid unit "{} " for first_of()' . format ( unit ) )
21972197
2198- dt = getattr (self , '_nth_of_%s' % unit )(nth , day_of_week )
2198+ dt = getattr (self , '_nth_of_{}' . format ( unit ) )(nth , day_of_week )
21992199 if dt is False :
2200- raise PendulumException ('Unable to find occurence %d of %s in %s'
2201- % ( nth , self ._days [day_of_week ], unit ))
2200+ raise PendulumException ('Unable to find occurence {} of {} in {}' . format (
2201+ nth , self ._days [day_of_week ], unit ))
22022202
22032203 return dt
22042204
@@ -2440,7 +2440,7 @@ def _get_datetime(self, value, pendulum=False):
24402440
24412441 return d ._datetime
24422442
2443- raise ValueError ('Invalid datetime "%s"' % value )
2443+ raise ValueError ('Invalid datetime "{}"' . format ( value ) )
24442444
24452445 def for_json (self ):
24462446 """
0 commit comments