@@ -289,7 +289,7 @@ class DayField:
289289 crontab week days and month days of the current month sequentially.
290290 """
291291
292- def __init__ (self , monthday_field : Field [MonthdayRange ], weekday_field : Field [WeekdayRange ], tz : dt .timezone ):
292+ def __init__ (self , monthday_field : Field [MonthdayRange ], weekday_field : Field [WeekdayRange ], tz : dt .tzinfo ):
293293 self ._monthday_field = monthday_field
294294 self ._weekday_field = weekday_field
295295 self ._tz = tz
@@ -378,7 +378,7 @@ class Crontab:
378378
379379 seconds_ext : bool = False
380380 years_ext : bool = False
381- tz : dt .timezone = dt .timezone .utc
381+ tz : dt .tzinfo = dt .timezone .utc
382382
383383 @property
384384 def day_field (self ) -> DayField :
@@ -407,7 +407,7 @@ def parse(
407407 expr : str ,
408408 seconds_ext : bool = False ,
409409 years_ext : bool = False ,
410- tz : dt .timezone = tzlocal .get_localzone (),
410+ tz : dt .tzinfo = tzlocal .get_localzone (),
411411 now : Optional [dt .datetime ] = None ,
412412 ) -> 'Crontab' :
413413 """
@@ -427,7 +427,7 @@ def parse(
427427 raise ValueError (f"crontab expression must be of { fields_number } fields" )
428428
429429 fields_iter = iter (fields )
430- now = now or dt .datetime .now (tz = tz )
430+ now = ( now or dt .datetime .now (tz = tz )). astimezone ( tz )
431431
432432 return cls (
433433 second_field = SecondsField .fromstr (next (fields_iter )) if seconds_ext else SecondsField .fromstr ('0' ),
@@ -439,7 +439,7 @@ def parse(
439439 year_field = YearField .fromstr (next (fields_iter )) if years_ext else YearField .fromstr (f'{ now .year } -2099' ),
440440 seconds_ext = seconds_ext ,
441441 years_ext = years_ext ,
442- tz = tz ,
442+ tz = now . tzinfo ,
443443 )
444444
445445 def __iter__ (self ) -> Iterator [dt .datetime ]:
@@ -461,6 +461,7 @@ def iter(self, start_from: dt.datetime) -> Iterator[dt.datetime]:
461461 :return: datetime iterator
462462 """
463463
464+ start_from = start_from .astimezone (self .tz )
464465 first_run = True
465466 year_iter = self .year_field .iter (start_from = start_from .year )
466467
0 commit comments