r4izddlmZddlmZmZmZmZmZddlmZddl m Z ddl m Z ddl mZmZmZGdde Zy ) ) annotations)datedatetimetime timedeltatzinfo)Any) get_localzone) BaseTrigger)asdate astimezone timezone_reprc eZdZdZdZdddddddddddd d dZ d dZd dZdd Zdd Z y)CalendarIntervalTriggeru Runs the task on specified calendar-based intervals always at the same exact time of day. When calculating the next date, the ``years`` and ``months`` parameters are first added to the previous date while keeping the day of the month constant. This is repeated until the resulting date is valid. After that, the ``weeks`` and ``days`` parameters are added to that date. Finally, the date is combined with the given time (hour, minute, second) to form the final datetime. This means that if the ``days`` or ``weeks`` parameters are not used, the task will always be executed on the same day of the month at the same wall clock time, assuming the date and time are valid. If the resulting datetime is invalid due to a daylight saving forward shift, the date is discarded and the process moves on to the next date. If instead the datetime is ambiguous due to a backward DST shift, the earlier of the two resulting datetimes is used. If no previous run time is specified when requesting a new run time (like when starting for the first time or resuming after being paused), ``start_date`` is used as a reference and the next valid datetime equal to or later than the current time will be returned. Otherwise, the next valid datetime starting from the previous run time is returned, even if it's in the past. .. warning:: Be wary of setting a start date near the end of the month (29. – 31.) if you have ``months`` specified in your interval, as this will skip the months when those days do not exist. Likewise, setting the start date on the leap day (February 29th) and having ``years`` defined may cause some years to be skipped. Users are also discouraged from using a time inside the target timezone's DST switching period (typically around 2 am) since a date could either be skipped or repeated due to the specified wall clock time either occurring twice or not at all. :param years: number of years to wait :param months: number of months to wait :param weeks: number of weeks to wait :param days: number of days to wait :param hour: hour to run the task at :param minute: minute to run the task at :param second: second to run the task at :param start_date: first date to trigger on (defaults to current date if omitted) :param end_date: latest possible date to trigger on :param timezone: time zone to use for calculating the next fire time (defaults to scheduler timezone if created via the scheduler, otherwise the local time zone) :param jitter: delay the job execution by ``jitter`` seconds at most ) yearsmonthsweeksdays start_dateend_datetimezonejitter_timerN) rrrrhourminutesecondrrrrc @| rt| |_ntt|_||_||_||_||_t|xstj|_ t| |_ | |_ t||||j|_|j|jcxk(r/|j cxk(r|j cxk(rdk(r td|jr%|j|jkDr tdyy)N)rrz$interval must be at least 1 day longz*end_date cannot be earlier than start_date)r rr rrrrr rtodayrrrrr ValueError) selfrrrrrrrrrrrs q/mnt/ssd/data/python-lab/DaemonControl/venv/lib/python3.12/site-packages/apscheduler/triggers/calendarinterval.py__init__z CalendarIntervalTrigger.__init__Os &x0DM&}7DM     ,< x(  $t}}E :: D Ddii D1 DCD D E ==T__t}}<IJ J==c |r|j|j}} ||jz }||j|dz dzzz }|dz dzdz} t |||j }|t |j|jdzzz }n |j}|jr||jkDrytj||jj}tj ||j"}|j%|jk7r|j }n|j'||j(|SQ#t$rYnwxYwG)N )yearmonthrrrdayrrrrrrrcombiner timestamp fromtimestamprtimetz _apply_jitterr)r previous_fire_timenowr(r) next_dater, next_times r!get_next_fire_timez*CalendarIntervalTrigger.get_next_fire_timersQ!0557I7O7OeT[[(EDJJ%!)):::D"QY",q0E$(u6H6L6L$M "Ytyy4::>/I%JJ  OO }}T]]!:!((DJJ?IIKI ..y$--HI!TZZ/%.^^%5")))T[[#FF;& sE EEc<d|j|j|j|jg|jj |jj |jjg|j|j|j|jdS)Nr%)versionintervalrrrrr) rrrrrrrrrrrr)r s r! __getstate__z$CalendarIntervalTrigger.__getstate__smT[[$**diiHZZ__djj&7&79J9JK//  kk  r#cF|jdddkDr)td|dd|jjd|d\|_|_|_|_|d|_|d|_ |d |_ |d |_ t|d d |ji|_ y) Nr6r%z Got serialized data for version z of z*, but only versions up to 1 can be handledr7rrrrrr)getr __class____name__rrrrrrrrrr)r states r! __setstate__z$CalendarIntervalTrigger.__setstate__s 99Y "Q &253C2DD>>**++UW  :?z9J6 DKTY -j) j) Ho 5=?? r#cg}dD]*}t||}|dkDs|j|d|,|jd|jj|jd|jd|j r|jd|j d|jdt |j|jjd d j|d S) N)rrrrr=ztime=z start_date=''z end_date='z timezone=(z, )) getattrappendr isoformatrrrrr;r<join)r fieldsfieldvalues r!__repr__z CalendarIntervalTrigger.__repr__s7 2ED%(Eqy q01 2  djj224789 T__$5Q78 == MMJt}}oQ7 8 - ">!ABC..))*!DIIf,=+>a@@r#)rintrrLrrLrrLrrLrrLrrLrdate | str | NonerrMrzstr | tzinfo | Nonerz int | None)r0datetime | Noner1rreturnrN)rOdict[str, Any])r=rPrONone)rOstr) r< __module__ __qualname____doc__ __slots__r"r4r8r>rKr#r!rrs0d I(,&*(,!!K!K !K  !K  !K!K!K!K&!K$!K&!K!KF G"1 G8@ G  GD   @ Ar#rN) __future__rrrrrrtypingr tzlocalr apscheduler.triggers.baser apscheduler.utilr r rrrWr#r!r]s1"<<!1jAkjAr#