Debian Codegraph @

jedi/third_party/typeshed/stdlib/calendar.pyi

raw symbols SCIP
1 import datetime
2 import enum
3 import sys
4 from _typeshed import Unused
5 from collections.abc import Iterable, Sequence
6 from time import struct_time
7 from typing import ClassVar, Final
8 from typing_extensions import TypeAlias
9
10 __all__ = [
11 "IllegalMonthError",
12 "IllegalWeekdayError",
13 "setfirstweekday",
14 "firstweekday",
15 "isleap",
16 "leapdays",
17 "weekday",
18 "monthrange",
19 "monthcalendar",
20 "prmonth",
21 "month",
22 "prcal",
23 "calendar",
24 "timegm",
25 "month_name",
26 "month_abbr",
27 "day_name",
28 "day_abbr",
29 "Calendar",
30 "TextCalendar",
31 "HTMLCalendar",
32 "LocaleTextCalendar",
33 "LocaleHTMLCalendar",
34 "weekheader",
35 ]
36
37 if sys.version_info >= (3, 10):
38 __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"]
39 if sys.version_info >= (3, 12):
40 __all__ += [
41 "Day",
42 "Month",
43 "JANUARY",
44 "FEBRUARY",
45 "MARCH",
46 "APRIL",
47 "MAY",
48 "JUNE",
49 "JULY",
50 "AUGUST",
51 "SEPTEMBER",
52 "OCTOBER",
53 "NOVEMBER",
54 "DECEMBER",
55 ]
56
57 _LocaleType: TypeAlias = tuple[str | None, str | None]
58
59 class IllegalMonthError(ValueError, IndexError):
60 month: int
61 def __init__(self, month: int) -> None: ...
62
63 class IllegalWeekdayError(ValueError):
64 weekday: int
65 def __init__(self, weekday: int) -> None: ...
66
67 def isleap(year: int) -> bool: ...
68 def leapdays(y1: int, y2: int) -> int: ...
69 def weekday(year: int, month: int, day: int) -> int: ...
70 def monthrange(year: int, month: int) -> tuple[int, int]: ...
71
72 class Calendar:
73 firstweekday: int
74 def __init__(self, firstweekday: int = 0) -> None: ...
75 def getfirstweekday(self) -> int: ...
76 def setfirstweekday(self, firstweekday: int) -> None: ...
77 def iterweekdays(self) -> Iterable[int]: ...
78 def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ...
79 def itermonthdays2(self, year: int, month: int) -> Iterable[tuple[int, int]]: ...
80 def itermonthdays(self, year: int, month: int) -> Iterable[int]: ...
81 def monthdatescalendar(self, year: int, month: int) -> list[list[datetime.date]]: ...
82 def monthdays2calendar(self, year: int, month: int) -> list[list[tuple[int, int]]]: ...
83 def monthdayscalendar(self, year: int, month: int) -> list[list[int]]: ...
84 def yeardatescalendar(self, year: int, width: int = 3) -> list[list[list[list[datetime.date]]]]: ...
85 def yeardays2calendar(self, year: int, width: int = 3) -> list[list[list[list[tuple[int, int]]]]]: ...
86 def yeardayscalendar(self, year: int, width: int = 3) -> list[list[list[list[int]]]]: ...
87 def itermonthdays3(self, year: int, month: int) -> Iterable[tuple[int, int, int]]: ...
88 def itermonthdays4(self, year: int, month: int) -> Iterable[tuple[int, int, int, int]]: ...
89
90 class TextCalendar(Calendar):
91 def prweek(self, theweek: int, width: int) -> None: ...
92 def formatday(self, day: int, weekday: int, width: int) -> str: ...
93 def formatweek(self, theweek: int, width: int) -> str: ...
94 def formatweekday(self, day: int, width: int) -> str: ...
95 def formatweekheader(self, width: int) -> str: ...
96 def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = True) -> str: ...
97 def prmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> None: ...
98 def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
99 def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
100 def pryear(self, theyear: int, w: int = 0, l: int = 0, c: int = 6, m: int = 3) -> None: ...
101
102 def firstweekday() -> int: ...
103 def monthcalendar(year: int, month: int) -> list[list[int]]: ...
104 def prweek(theweek: int, width: int) -> None: ...
105 def week(theweek: int, width: int) -> str: ...
106 def weekheader(width: int) -> str: ...
107 def prmonth(theyear: int, themonth: int, w: int = 0, l: int = 0) -> None: ...
108 def month(theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
109 def calendar(theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
110 def prcal(theyear: int, w: int = 0, l: int = 0, c: int = 6, m: int = 3) -> None: ...
111
112 class HTMLCalendar(Calendar):
113 cssclasses: ClassVar[list[str]]
114 cssclass_noday: ClassVar[str]
115 cssclasses_weekday_head: ClassVar[list[str]]
116 cssclass_month_head: ClassVar[str]
117 cssclass_month: ClassVar[str]
118 cssclass_year: ClassVar[str]
119 cssclass_year_head: ClassVar[str]
120 def formatday(self, day: int, weekday: int) -> str: ...
121 def formatweek(self, theweek: int) -> str: ...
122 def formatweekday(self, day: int) -> str: ...
123 def formatweekheader(self) -> str: ...
124 def formatmonthname(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
125 def formatmonth(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
126 def formatyear(self, theyear: int, width: int = 3) -> str: ...
127 def formatyearpage(
128 self, theyear: int, width: int = 3, css: str | None = "calendar.css", encoding: str | None = None
129 ) -> bytes: ...
130
131 class different_locale:
132 def __init__(self, locale: _LocaleType) -> None: ...
133 def __enter__(self) -> None: ...
134 def __exit__(self, *args: Unused) -> None: ...
135
136 class LocaleTextCalendar(TextCalendar):
137 def __init__(self, firstweekday: int = 0, locale: _LocaleType | None = None) -> None: ...
138
139 class LocaleHTMLCalendar(HTMLCalendar):
140 def __init__(self, firstweekday: int = 0, locale: _LocaleType | None = None) -> None: ...
141 def formatweekday(self, day: int) -> str: ...
142 def formatmonthname(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
143
144 c: TextCalendar
145
146 def setfirstweekday(firstweekday: int) -> None: ...
147 def format(cols: int, colwidth: int = 20, spacing: int = 6) -> str: ...
148 def formatstring(cols: int, colwidth: int = 20, spacing: int = 6) -> str: ...
149 def timegm(tuple: tuple[int, ...] | struct_time) -> int: ...
150
151 # Data attributes
152 day_name: Sequence[str]
153 day_abbr: Sequence[str]
154 month_name: Sequence[str]
155 month_abbr: Sequence[str]
156
157 if sys.version_info >= (3, 12):
158 class Month(enum.IntEnum):
159 JANUARY = 1
160 FEBRUARY = 2
161 MARCH = 3
162 APRIL = 4
163 MAY = 5
164 JUNE = 6
165 JULY = 7
166 AUGUST = 8
167 SEPTEMBER = 9
168 OCTOBER = 10
169 NOVEMBER = 11
170 DECEMBER = 12
171
172 JANUARY: Final = Month.JANUARY
173 FEBRUARY: Final = Month.FEBRUARY
174 MARCH: Final = Month.MARCH
175 APRIL: Final = Month.APRIL
176 MAY: Final = Month.MAY
177 JUNE: Final = Month.JUNE
178 JULY: Final = Month.JULY
179 AUGUST: Final = Month.AUGUST
180 SEPTEMBER: Final = Month.SEPTEMBER
181 OCTOBER: Final = Month.OCTOBER
182 NOVEMBER: Final = Month.NOVEMBER
183 DECEMBER: Final = Month.DECEMBER
184
185 class Day(enum.IntEnum):
186 MONDAY = 0
187 TUESDAY = 1
188 WEDNESDAY = 2
189 THURSDAY = 3
190 FRIDAY = 4
191 SATURDAY = 5
192 SUNDAY = 6
193
194 MONDAY: Final = Day.MONDAY
195 TUESDAY: Final = Day.TUESDAY
196 WEDNESDAY: Final = Day.WEDNESDAY
197 THURSDAY: Final = Day.THURSDAY
198 FRIDAY: Final = Day.FRIDAY
199 SATURDAY: Final = Day.SATURDAY
200 SUNDAY: Final = Day.SUNDAY
201 else:
202 MONDAY: Final = 0
203 TUESDAY: Final = 1
204 WEDNESDAY: Final = 2
205 THURSDAY: Final = 3
206 FRIDAY: Final = 4
207 SATURDAY: Final = 5
208 SUNDAY: Final = 6
209
210 EPOCH: Final = 1970