diff --git a/clock b/clock index 3c21a160..acd8c558 100755 --- a/clock +++ b/clock @@ -112,8 +112,8 @@ translations = {{}} data["days"] = {} for fmt, names in days.items(): data["days"][fmt] = {} - for value, name in names.items(): - data["days"][fmt][(value + 1) % 7] = name + for value, name in sorted(names.items()): + data["days"][fmt][value] = name # Getting months names months = content["months"]["format"] @@ -158,6 +158,9 @@ translations = {{}} # Day periods data["day_periods"] = content["day_periods"]["format"]["wide"] + # Week data + data["week_data"] = content["week_data"] + result = self.TEMPLATE.format( locale=locale, plural=plural, @@ -238,7 +241,7 @@ class LocaleRecreate(Command): locales = glob.glob(os.path.join(locales_dir, "*", "locale.py")) locales = [os.path.basename(os.path.dirname(locale)) for locale in locales] - self.call("locale:create", [("locales", locales)]) + self.call("locale create", "locales " + " ".join(locales)) class WindowsTzDump(Command): diff --git a/pendulum/__init__.py b/pendulum/__init__.py index 9c019c0f..76763ce9 100644 --- a/pendulum/__init__.py +++ b/pendulum/__init__.py @@ -8,24 +8,18 @@ from pendulum.__version__ import __version__ from pendulum.constants import DAYS_PER_WEEK -from pendulum.constants import FRIDAY from pendulum.constants import HOURS_PER_DAY from pendulum.constants import MINUTES_PER_HOUR -from pendulum.constants import MONDAY from pendulum.constants import MONTHS_PER_YEAR -from pendulum.constants import SATURDAY from pendulum.constants import SECONDS_PER_DAY from pendulum.constants import SECONDS_PER_HOUR from pendulum.constants import SECONDS_PER_MINUTE -from pendulum.constants import SUNDAY -from pendulum.constants import THURSDAY -from pendulum.constants import TUESDAY -from pendulum.constants import WEDNESDAY from pendulum.constants import WEEKS_PER_YEAR from pendulum.constants import YEARS_PER_CENTURY from pendulum.constants import YEARS_PER_DECADE from pendulum.date import Date from pendulum.datetime import DateTime +from pendulum.day import WeekDay from pendulum.duration import Duration from pendulum.formatting import Formatter from pendulum.helpers import format_diff @@ -48,10 +42,19 @@ from pendulum.tz.timezone import Timezone +MONDAY = WeekDay.MONDAY +TUESDAY = WeekDay.TUESDAY +WEDNESDAY = WeekDay.WEDNESDAY +THURSDAY = WeekDay.THURSDAY +FRIDAY = WeekDay.FRIDAY +SATURDAY = WeekDay.SATURDAY +SUNDAY = WeekDay.SUNDAY + + _TEST_NOW: DateTime | None = None _LOCALE = "en" -_WEEK_STARTS_AT = MONDAY -_WEEK_ENDS_AT = SUNDAY +_WEEK_STARTS_AT: WeekDay = WeekDay.MONDAY +_WEEK_ENDS_AT: WeekDay = WeekDay.SUNDAY _formatter = Formatter() @@ -335,19 +338,12 @@ def interval(start: DateTime, end: DateTime, absolute: bool = False) -> Interval __all__ = [ "__version__", "DAYS_PER_WEEK", - "FRIDAY", "HOURS_PER_DAY", "MINUTES_PER_HOUR", - "MONDAY", "MONTHS_PER_YEAR", - "SATURDAY", "SECONDS_PER_DAY", "SECONDS_PER_HOUR", "SECONDS_PER_MINUTE", - "SUNDAY", - "THURSDAY", - "TUESDAY", - "WEDNESDAY", "WEEKS_PER_YEAR", "YEARS_PER_CENTURY", "YEARS_PER_DECADE", @@ -355,6 +351,7 @@ def interval(start: DateTime, end: DateTime, absolute: bool = False) -> Interval "DateTime", "Duration", "Formatter", + "WeekDay", "date", "datetime", "duration", diff --git a/pendulum/constants.py b/pendulum/constants.py index c7b3876a..51eb0590 100644 --- a/pendulum/constants.py +++ b/pendulum/constants.py @@ -2,14 +2,6 @@ from __future__ import annotations -SUNDAY = 0 -MONDAY = 1 -TUESDAY = 2 -WEDNESDAY = 3 -THURSDAY = 4 -FRIDAY = 5 -SATURDAY = 6 - # Number of X in Y. YEARS_PER_CENTURY = 100 YEARS_PER_DECADE = 10 diff --git a/pendulum/date.py b/pendulum/date.py index 41d80e77..772f1ac1 100644 --- a/pendulum/date.py +++ b/pendulum/date.py @@ -16,16 +16,10 @@ import pendulum -from pendulum.constants import FRIDAY -from pendulum.constants import MONDAY from pendulum.constants import MONTHS_PER_YEAR -from pendulum.constants import SATURDAY -from pendulum.constants import SUNDAY -from pendulum.constants import THURSDAY -from pendulum.constants import TUESDAY -from pendulum.constants import WEDNESDAY from pendulum.constants import YEARS_PER_CENTURY from pendulum.constants import YEARS_PER_DECADE +from pendulum.day import WeekDay from pendulum.exceptions import PendulumException from pendulum.helpers import add_duration from pendulum.interval import Interval @@ -38,17 +32,6 @@ class Date(FormattableMixin, date): - # Names of days of the week - _days: ClassVar[dict[int, str]] = { - SUNDAY: "Sunday", - MONDAY: "Monday", - TUESDAY: "Tuesday", - WEDNESDAY: "Wednesday", - THURSDAY: "Thursday", - FRIDAY: "Friday", - SATURDAY: "Saturday", - } - _MODIFIERS_VALID_UNITS: ClassVar[list[str]] = [ "day", "week", @@ -66,11 +49,11 @@ def set( return self.replace(year=year, month=month, day=day) @property - def day_of_week(self) -> int: + def day_of_week(self) -> WeekDay: """ Returns the day of the week (0-6). """ - return self.isoweekday() % 7 + return WeekDay(self.weekday()) @property def day_of_year(self) -> int: @@ -479,7 +462,7 @@ def _end_of_week(self) -> Self: return dt.end_of("day") - def next(self, day_of_week: int | None = None) -> Self: + def next(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the next occurrence of a given day of the week. If no day_of_week is provided, modify to the next occurrence @@ -491,7 +474,7 @@ def next(self, day_of_week: int | None = None) -> Self: if day_of_week is None: day_of_week = self.day_of_week - if day_of_week < SUNDAY or day_of_week > SATURDAY: + if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: raise ValueError("Invalid day of week") dt = self.add(days=1) @@ -500,7 +483,7 @@ def next(self, day_of_week: int | None = None) -> Self: return dt - def previous(self, day_of_week: int | None = None) -> Self: + def previous(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the previous occurrence of a given day of the week. If no day_of_week is provided, modify to the previous occurrence @@ -512,7 +495,7 @@ def previous(self, day_of_week: int | None = None) -> Self: if day_of_week is None: day_of_week = self.day_of_week - if day_of_week < SUNDAY or day_of_week > SATURDAY: + if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: raise ValueError("Invalid day of week") dt = self.subtract(days=1) @@ -521,7 +504,7 @@ def previous(self, day_of_week: int | None = None) -> Self: return dt - def first_of(self, unit: str, day_of_week: int | None = None) -> Self: + def first_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: """ Returns an instance set to the first occurrence of a given day of the week in the current unit. @@ -539,7 +522,7 @@ def first_of(self, unit: str, day_of_week: int | None = None) -> Self: return cast("Self", getattr(self, f"_first_of_{unit}")(day_of_week)) - def last_of(self, unit: str, day_of_week: int | None = None) -> Self: + def last_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: """ Returns an instance set to the last occurrence of a given day of the week in the current unit. @@ -557,7 +540,7 @@ def last_of(self, unit: str, day_of_week: int | None = None) -> Self: return cast("Self", getattr(self, f"_last_of_{unit}")(day_of_week)) - def nth_of(self, unit: str, nth: int, day_of_week: int) -> Self: + def nth_of(self, unit: str, nth: int, day_of_week: WeekDay) -> Self: """ Returns a new instance set to the given occurrence of a given day of the week in the current unit. @@ -578,12 +561,12 @@ def nth_of(self, unit: str, nth: int, day_of_week: int) -> Self: if not dt: raise PendulumException( f"Unable to find occurence {nth}" - f" of {self._days[day_of_week]} in {unit}" + f" of {WeekDay(day_of_week).name.capitalize()} in {unit}" ) return dt - def _first_of_month(self, day_of_week: int) -> Self: + def _first_of_month(self, day_of_week: WeekDay) -> Self: """ Modify to the first occurrence of a given day of the week in the current month. If no day_of_week is provided, @@ -599,7 +582,7 @@ def _first_of_month(self, day_of_week: int) -> Self: month = calendar.monthcalendar(dt.year, dt.month) - calendar_day = (day_of_week - 1) % 7 + calendar_day = day_of_week if month[0][calendar_day] > 0: day_of_month = month[0][calendar_day] @@ -608,7 +591,7 @@ def _first_of_month(self, day_of_week: int) -> Self: return dt.set(day=day_of_month) - def _last_of_month(self, day_of_week: int | None = None) -> Self: + def _last_of_month(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current month. If no day_of_week is provided, @@ -624,7 +607,7 @@ def _last_of_month(self, day_of_week: int | None = None) -> Self: month = calendar.monthcalendar(dt.year, dt.month) - calendar_day = (day_of_week - 1) % 7 + calendar_day = day_of_week if month[-1][calendar_day] > 0: day_of_month = month[-1][calendar_day] @@ -633,7 +616,7 @@ def _last_of_month(self, day_of_week: int | None = None) -> Self: return dt.set(day=day_of_month) - def _nth_of_month(self, nth: int, day_of_week: int) -> Self | None: + def _nth_of_month(self, nth: int, day_of_week: WeekDay) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside, @@ -654,7 +637,7 @@ def _nth_of_month(self, nth: int, day_of_week: int) -> Self | None: return None - def _first_of_quarter(self, day_of_week: int | None = None) -> Self: + def _first_of_quarter(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the first occurrence of a given day of the week in the current quarter. If no day_of_week is provided, @@ -665,7 +648,7 @@ def _first_of_quarter(self, day_of_week: int | None = None) -> Self: "month", day_of_week ) - def _last_of_quarter(self, day_of_week: int | None = None) -> Self: + def _last_of_quarter(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current quarter. If no day_of_week is provided, @@ -674,7 +657,7 @@ def _last_of_quarter(self, day_of_week: int | None = None) -> Self: """ return self.set(self.year, self.quarter * 3, 1).last_of("month", day_of_week) - def _nth_of_quarter(self, nth: int, day_of_week: int) -> Self | None: + def _nth_of_quarter(self, nth: int, day_of_week: WeekDay) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside, @@ -697,7 +680,7 @@ def _nth_of_quarter(self, nth: int, day_of_week: int) -> Self | None: return self.set(self.year, dt.month, dt.day) - def _first_of_year(self, day_of_week: int | None = None) -> Self: + def _first_of_year(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the first occurrence of a given day of the week in the current year. If no day_of_week is provided, @@ -706,7 +689,7 @@ def _first_of_year(self, day_of_week: int | None = None) -> Self: """ return self.set(month=1).first_of("month", day_of_week) - def _last_of_year(self, day_of_week: int | None = None) -> Self: + def _last_of_year(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current year. If no day_of_week is provided, @@ -715,7 +698,7 @@ def _last_of_year(self, day_of_week: int | None = None) -> Self: """ return self.set(month=MONTHS_PER_YEAR).last_of("month", day_of_week) - def _nth_of_year(self, nth: int, day_of_week: int) -> Self | None: + def _nth_of_year(self, nth: int, day_of_week: WeekDay) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside, diff --git a/pendulum/datetime.py b/pendulum/datetime.py index d036d255..5f369100 100644 --- a/pendulum/datetime.py +++ b/pendulum/datetime.py @@ -25,14 +25,13 @@ from pendulum.constants import RFC1123 from pendulum.constants import RFC2822 from pendulum.constants import RSS -from pendulum.constants import SATURDAY from pendulum.constants import SECONDS_PER_DAY from pendulum.constants import SECONDS_PER_MINUTE -from pendulum.constants import SUNDAY from pendulum.constants import W3C from pendulum.constants import YEARS_PER_CENTURY from pendulum.constants import YEARS_PER_DECADE from pendulum.date import Date +from pendulum.day import WeekDay from pendulum.exceptions import PendulumException from pendulum.helpers import add_duration from pendulum.interval import Interval @@ -902,7 +901,7 @@ def _end_of_week(self) -> Self: return dt.end_of("day") - def next(self, day_of_week: int | None = None, keep_time: bool = False) -> Self: + def next(self, day_of_week: WeekDay | None = None, keep_time: bool = False) -> Self: """ Modify to the next occurrence of a given day of the week. If no day_of_week is provided, modify to the next occurrence @@ -912,7 +911,7 @@ def next(self, day_of_week: int | None = None, keep_time: bool = False) -> Self: if day_of_week is None: day_of_week = self.day_of_week - if day_of_week < SUNDAY or day_of_week > SATURDAY: + if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: raise ValueError("Invalid day of week") dt = self if keep_time else self.start_of("day") @@ -923,7 +922,9 @@ def next(self, day_of_week: int | None = None, keep_time: bool = False) -> Self: return dt - def previous(self, day_of_week: int | None = None, keep_time: bool = False) -> Self: + def previous( + self, day_of_week: WeekDay | None = None, keep_time: bool = False + ) -> Self: """ Modify to the previous occurrence of a given day of the week. If no day_of_week is provided, modify to the previous occurrence @@ -933,7 +934,7 @@ def previous(self, day_of_week: int | None = None, keep_time: bool = False) -> S if day_of_week is None: day_of_week = self.day_of_week - if day_of_week < SUNDAY or day_of_week > SATURDAY: + if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: raise ValueError("Invalid day of week") dt = self if keep_time else self.start_of("day") @@ -944,7 +945,7 @@ def previous(self, day_of_week: int | None = None, keep_time: bool = False) -> S return dt - def first_of(self, unit: str, day_of_week: int | None = None) -> Self: + def first_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: """ Returns an instance set to the first occurrence of a given day of the week in the current unit. @@ -959,7 +960,7 @@ def first_of(self, unit: str, day_of_week: int | None = None) -> Self: return cast("Self", getattr(self, f"_first_of_{unit}")(day_of_week)) - def last_of(self, unit: str, day_of_week: int | None = None) -> Self: + def last_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: """ Returns an instance set to the last occurrence of a given day of the week in the current unit. @@ -974,7 +975,7 @@ def last_of(self, unit: str, day_of_week: int | None = None) -> Self: return cast("Self", getattr(self, f"_last_of_{unit}")(day_of_week)) - def nth_of(self, unit: str, nth: int, day_of_week: int) -> Self: + def nth_of(self, unit: str, nth: int, day_of_week: WeekDay) -> Self: """ Returns a new instance set to the given occurrence of a given day of the week in the current unit. @@ -991,12 +992,12 @@ def nth_of(self, unit: str, nth: int, day_of_week: int) -> Self: if not dt: raise PendulumException( f"Unable to find occurence {nth}" - f" of {self._days[day_of_week]} in {unit}" + f" of {WeekDay(day_of_week).name.capitalize()} in {unit}" ) return dt - def _first_of_month(self, day_of_week: int | None = None) -> Self: + def _first_of_month(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the first occurrence of a given day of the week in the current month. If no day_of_week is provided, @@ -1010,7 +1011,7 @@ def _first_of_month(self, day_of_week: int | None = None) -> Self: month = calendar.monthcalendar(dt.year, dt.month) - calendar_day = (day_of_week - 1) % 7 + calendar_day = day_of_week if month[0][calendar_day] > 0: day_of_month = month[0][calendar_day] @@ -1019,7 +1020,7 @@ def _first_of_month(self, day_of_week: int | None = None) -> Self: return dt.set(day=day_of_month) - def _last_of_month(self, day_of_week: int | None = None) -> Self: + def _last_of_month(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current month. If no day_of_week is provided, @@ -1033,7 +1034,7 @@ def _last_of_month(self, day_of_week: int | None = None) -> Self: month = calendar.monthcalendar(dt.year, dt.month) - calendar_day = (day_of_week - 1) % 7 + calendar_day = day_of_week if month[-1][calendar_day] > 0: day_of_month = month[-1][calendar_day] @@ -1042,7 +1043,9 @@ def _last_of_month(self, day_of_week: int | None = None) -> Self: return dt.set(day=day_of_month) - def _nth_of_month(self, nth: int, day_of_week: int | None = None) -> Self | None: + def _nth_of_month( + self, nth: int, day_of_week: WeekDay | None = None + ) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside, @@ -1063,7 +1066,7 @@ def _nth_of_month(self, nth: int, day_of_week: int | None = None) -> Self | None return None - def _first_of_quarter(self, day_of_week: int | None = None) -> Self: + def _first_of_quarter(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the first occurrence of a given day of the week in the current quarter. If no day_of_week is provided, @@ -1074,7 +1077,7 @@ def _first_of_quarter(self, day_of_week: int | None = None) -> Self: "month", day_of_week ) - def _last_of_quarter(self, day_of_week: int | None = None) -> Self: + def _last_of_quarter(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current quarter. If no day_of_week is provided, @@ -1083,7 +1086,9 @@ def _last_of_quarter(self, day_of_week: int | None = None) -> Self: """ return self.on(self.year, self.quarter * 3, 1).last_of("month", day_of_week) - def _nth_of_quarter(self, nth: int, day_of_week: int | None = None) -> Self | None: + def _nth_of_quarter( + self, nth: int, day_of_week: WeekDay | None = None + ) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside, @@ -1106,7 +1111,7 @@ def _nth_of_quarter(self, nth: int, day_of_week: int | None = None) -> Self | No return self.on(self.year, dt.month, dt.day).start_of("day") - def _first_of_year(self, day_of_week: int | None = None) -> Self: + def _first_of_year(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the first occurrence of a given day of the week in the current year. If no day_of_week is provided, @@ -1115,7 +1120,7 @@ def _first_of_year(self, day_of_week: int | None = None) -> Self: """ return self.set(month=1).first_of("month", day_of_week) - def _last_of_year(self, day_of_week: int | None = None) -> Self: + def _last_of_year(self, day_of_week: WeekDay | None = None) -> Self: """ Modify to the last occurrence of a given day of the week in the current year. If no day_of_week is provided, @@ -1124,7 +1129,7 @@ def _last_of_year(self, day_of_week: int | None = None) -> Self: """ return self.set(month=MONTHS_PER_YEAR).last_of("month", day_of_week) - def _nth_of_year(self, nth: int, day_of_week: int | None = None) -> Self | None: + def _nth_of_year(self, nth: int, day_of_week: WeekDay | None = None) -> Self | None: """ Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside, diff --git a/pendulum/day.py b/pendulum/day.py new file mode 100644 index 00000000..7bfffca1 --- /dev/null +++ b/pendulum/day.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from enum import IntEnum + + +class WeekDay(IntEnum): + MONDAY = 0 + TUESDAY = 1 + WEDNESDAY = 2 + THURSDAY = 3 + FRIDAY = 4 + SATURDAY = 5 + SUNDAY = 6 diff --git a/pendulum/formatting/formatter.py b/pendulum/formatting/formatter.py index d8d13f65..ee04063f 100644 --- a/pendulum/formatting/formatter.py +++ b/pendulum/formatting/formatter.py @@ -49,7 +49,7 @@ class Formatter: r"\[([^\[]*)\]|\\(.)|" "(" "Mo|MM?M?M?" - "|Do|DDDo|DD?D?D?|ddd?d?|do?" + "|Do|DDDo|DD?D?D?|ddd?d?|do?|eo?" "|E{1,4}" "|w[o|w]?|W[o|W]?|Qo?" "|YYYY|YY|Y" @@ -82,6 +82,8 @@ class Formatter: "ddd": "days.abbreviated", "dd": "days.short", "do": None, + "e": None, + "eo": None, "Wo": None, "wo": None, "A": lambda locale: ( @@ -111,7 +113,7 @@ class Formatter: "DDDD": lambda dt: f"{dt.day_of_year:03d}", "DDD": lambda dt: f"{dt.day_of_year:d}", # Day of Week - "d": lambda dt: f"{dt.day_of_week:d}", + "d": lambda dt: f"{(dt.day_of_week + 1) % 7:d}", # Day of ISO Week "E": lambda dt: f"{dt.isoweekday():d}", # Hour @@ -176,6 +178,7 @@ class Formatter: "ddd": _MATCH_WORD, "dd": _MATCH_WORD, "d": _MATCH_1, + "e": _MATCH_1, "E": _MATCH_1, "Do": None, "H": _MATCH_1_TO_2, @@ -214,8 +217,8 @@ class Formatter: "dddd": lambda weekday: weekday, "ddd": lambda weekday: weekday, "dd": lambda weekday: weekday, - "d": lambda weekday: int(weekday) % 7, - "E": lambda weekday: int(weekday), + "d": lambda weekday: int(weekday), + "E": lambda weekday: int(weekday) - 1, "HH": lambda hour: int(hour), "H": lambda hour: int(hour), "hh": lambda hour: int(hour), @@ -318,14 +321,19 @@ def _format_localizable_token( return cast(str, locale.get("translations.days.short")[dt.day_of_week]) elif token == "ddd": return cast( - str, locale.get("translations.days.abbreviated")[dt.day_of_week] + str, + locale.get("translations.days.abbreviated")[dt.day_of_week], ) elif token == "dddd": return cast(str, locale.get("translations.days.wide")[dt.day_of_week]) + elif token == "e": + first_day = cast(int, locale.get("translations.week_data.first_day")) + + return str((dt.day_of_week % 7 - first_day) % 7) elif token == "Do": return locale.ordinalize(dt.day) elif token == "do": - return locale.ordinalize(dt.day_of_week) + return locale.ordinalize((dt.day_of_week + 1) % 7) elif token == "Mo": return locale.ordinalize(dt.month) elif token == "Qo": @@ -334,6 +342,10 @@ def _format_localizable_token( return locale.ordinalize(dt.week_of_year) elif token == "DDDo": return locale.ordinalize(dt.day_of_year) + elif token == "eo": + first_day = cast(int, locale.get("translations.week_data.first_day")) + + return locale.ordinalize((dt.day_of_week % 7 - first_day) % 7 + 1) elif token == "A": key = "translations.day_periods" if dt.hour >= 12: diff --git a/pendulum/helpers.py b/pendulum/helpers.py index e9390ca9..87ed6871 100644 --- a/pendulum/helpers.py +++ b/pendulum/helpers.py @@ -14,6 +14,7 @@ import pendulum from pendulum.constants import DAYS_PER_MONTHS +from pendulum.day import WeekDay from pendulum.formatting.difference_formatter import DifferenceFormatter from pendulum.locales.locale import Locale @@ -188,16 +189,16 @@ def get_locale() -> str: return pendulum._LOCALE -def week_starts_at(wday: int) -> None: - if wday < pendulum.SUNDAY or wday > pendulum.SATURDAY: - raise ValueError("Invalid week day as start of week.") +def week_starts_at(wday: WeekDay) -> None: + if wday < WeekDay.MONDAY or wday > WeekDay.SUNDAY: + raise ValueError("Invalid day of week") pendulum._WEEK_STARTS_AT = wday -def week_ends_at(wday: int) -> None: - if wday < pendulum.SUNDAY or wday > pendulum.SATURDAY: - raise ValueError("Invalid week day as start of week.") +def week_ends_at(wday: WeekDay) -> None: + if wday < WeekDay.MONDAY or wday > WeekDay.SUNDAY: + raise ValueError("Invalid day of week") pendulum._WEEK_ENDS_AT = wday diff --git a/pendulum/locales/cs/locale.py b/pendulum/locales/cs/locale.py index 2c51c786..d7b38bdf 100644 --- a/pendulum/locales/cs/locale.py +++ b/pendulum/locales/cs/locale.py @@ -20,40 +20,40 @@ "translations": { "days": { "abbreviated": { - 0: "ne", - 1: "po", - 2: "út", - 3: "st", - 4: "čt", - 5: "pá", - 6: "so", + 0: "po", + 1: "út", + 2: "st", + 3: "čt", + 4: "pá", + 5: "so", + 6: "ne", }, "narrow": { - 0: "N", - 1: "P", - 2: "Ú", - 3: "S", - 4: "Č", - 5: "P", - 6: "S", + 0: "P", + 1: "Ú", + 2: "S", + 3: "Č", + 4: "P", + 5: "S", + 6: "N", }, "short": { - 0: "ne", - 1: "po", - 2: "út", - 3: "st", - 4: "čt", - 5: "pá", - 6: "so", + 0: "po", + 1: "út", + 2: "st", + 3: "čt", + 4: "pá", + 5: "so", + 6: "ne", }, "wide": { - 0: "neděle", - 1: "pondělí", - 2: "úterý", - 3: "středa", - 4: "čtvrtek", - 5: "pátek", - 6: "sobota", + 0: "pondělí", + 1: "úterý", + 2: "středa", + 3: "čtvrtek", + 4: "pátek", + 5: "sobota", + 6: "neděle", }, }, "months": { @@ -261,6 +261,12 @@ "evening1": "večer", "night1": "v noci", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/da/locale.py b/pendulum/locales/da/locale.py index 936af3ab..968e1d6f 100644 --- a/pendulum/locales/da/locale.py +++ b/pendulum/locales/da/locale.py @@ -19,24 +19,24 @@ "translations": { "days": { "abbreviated": { - 0: "søn.", - 1: "man.", - 2: "tir.", - 3: "ons.", - 4: "tor.", - 5: "fre.", - 6: "lør.", + 0: "man.", + 1: "tir.", + 2: "ons.", + 3: "tor.", + 4: "fre.", + 5: "lør.", + 6: "søn.", }, - "narrow": {0: "S", 1: "M", 2: "T", 3: "O", 4: "T", 5: "F", 6: "L"}, - "short": {0: "sø", 1: "ma", 2: "ti", 3: "on", 4: "to", 5: "fr", 6: "lø"}, + "narrow": {0: "M", 1: "T", 2: "O", 3: "T", 4: "F", 5: "L", 6: "S"}, + "short": {0: "ma", 1: "ti", 2: "on", 3: "to", 4: "fr", 5: "lø", 6: "sø"}, "wide": { - 0: "søndag", - 1: "mandag", - 2: "tirsdag", - 3: "onsdag", - 4: "torsdag", - 5: "fredag", - 6: "lørdag", + 0: "mandag", + 1: "tirsdag", + 2: "onsdag", + 3: "torsdag", + 4: "fredag", + 5: "lørdag", + 6: "søndag", }, }, "months": { @@ -142,6 +142,12 @@ "evening1": "om aftenen", "night1": "om natten", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/de/locale.py b/pendulum/locales/de/locale.py index 94d2ff1a..28e631cc 100644 --- a/pendulum/locales/de/locale.py +++ b/pendulum/locales/de/locale.py @@ -16,32 +16,32 @@ "translations": { "days": { "abbreviated": { - 0: "So.", - 1: "Mo.", - 2: "Di.", - 3: "Mi.", - 4: "Do.", - 5: "Fr.", - 6: "Sa.", + 0: "Mo.", + 1: "Di.", + 2: "Mi.", + 3: "Do.", + 4: "Fr.", + 5: "Sa.", + 6: "So.", }, - "narrow": {0: "S", 1: "M", 2: "D", 3: "M", 4: "D", 5: "F", 6: "S"}, + "narrow": {0: "M", 1: "D", 2: "M", 3: "D", 4: "F", 5: "S", 6: "S"}, "short": { - 0: "So.", - 1: "Mo.", - 2: "Di.", - 3: "Mi.", - 4: "Do.", - 5: "Fr.", - 6: "Sa.", + 0: "Mo.", + 1: "Di.", + 2: "Mi.", + 3: "Do.", + 4: "Fr.", + 5: "Sa.", + 6: "So.", }, "wide": { - 0: "Sonntag", - 1: "Montag", - 2: "Dienstag", - 3: "Mittwoch", - 4: "Donnerstag", - 5: "Freitag", - 6: "Samstag", + 0: "Montag", + 1: "Dienstag", + 2: "Mittwoch", + 3: "Donnerstag", + 4: "Freitag", + 5: "Samstag", + 6: "Sonntag", }, }, "months": { @@ -139,6 +139,12 @@ "evening1": "abends", "night1": "nachts", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/en/locale.py b/pendulum/locales/en/locale.py index 00eafc2f..08b0b85e 100644 --- a/pendulum/locales/en/locale.py +++ b/pendulum/locales/en/locale.py @@ -31,24 +31,24 @@ "translations": { "days": { "abbreviated": { - 0: "Sun", - 1: "Mon", - 2: "Tue", - 3: "Wed", - 4: "Thu", - 5: "Fri", - 6: "Sat", + 0: "Mon", + 1: "Tue", + 2: "Wed", + 3: "Thu", + 4: "Fri", + 5: "Sat", + 6: "Sun", }, - "narrow": {0: "S", 1: "M", 2: "T", 3: "W", 4: "T", 5: "F", 6: "S"}, - "short": {0: "Su", 1: "Mo", 2: "Tu", 3: "We", 4: "Th", 5: "Fr", 6: "Sa"}, + "narrow": {0: "M", 1: "T", 2: "W", 3: "T", 4: "F", 5: "S", 6: "S"}, + "short": {0: "Mo", 1: "Tu", 2: "We", 3: "Th", 4: "Fr", 5: "Sa", 6: "Su"}, "wide": { - 0: "Sunday", - 1: "Monday", - 2: "Tuesday", - 3: "Wednesday", - 4: "Thursday", - 5: "Friday", - 6: "Saturday", + 0: "Monday", + 1: "Tuesday", + 2: "Wednesday", + 3: "Thursday", + 4: "Friday", + 5: "Saturday", + 6: "Sunday", }, }, "months": { @@ -145,6 +145,12 @@ "evening1": "in the evening", "night1": "at night", }, + "week_data": { + "min_days": 1, + "first_day": 6, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/en_gb/__init__.py b/pendulum/locales/en_gb/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pendulum/locales/en_gb/custom.py b/pendulum/locales/en_gb/custom.py new file mode 100644 index 00000000..f6f6353f --- /dev/null +++ b/pendulum/locales/en_gb/custom.py @@ -0,0 +1,23 @@ +""" +en-gb custom locale file. +""" + +translations = { + "units": {"few_second": "a few seconds"}, + # Relative time + "ago": "{} ago", + "from_now": "in {}", + "after": "{0} after", + "before": "{0} before", + # Ordinals + "ordinal": {"one": "st", "two": "nd", "few": "rd", "other": "th"}, + # Date formats + "date_formats": { + "LTS": "HH:mm:ss", + "LT": "HH:mm", + "L": "DD/MM/YYYY", + "LL": "D MMMM YYYY", + "LLL": "D MMMM YYYY HH:mm", + "LLLL": "dddd, D MMMM YYYY HH:mm", + }, +} diff --git a/pendulum/locales/en_gb/locale.py b/pendulum/locales/en_gb/locale.py new file mode 100644 index 00000000..7ff8ad64 --- /dev/null +++ b/pendulum/locales/en_gb/locale.py @@ -0,0 +1,238 @@ +from .custom import translations as custom_translations + + +""" +en-gb locale file. + +It has been generated automatically and must not be modified directly. +""" + + +locale = { + "plural": lambda n: "one" + if ((n == n and ((n == 1))) and (0 == 0 and ((0 == 0)))) + else "other", + "ordinal": lambda n: "few" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 3))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 13)))) + ) + else "one" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 1))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 11)))) + ) + else "two" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 2))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 12)))) + ) + else "other", + "translations": { + "days": { + "abbreviated": { + 0: "Mon", + 1: "Tue", + 2: "Wed", + 3: "Thu", + 4: "Fri", + 5: "Sat", + 6: "Sun", + }, + "narrow": { + 0: "M", + 1: "T", + 2: "W", + 3: "T", + 4: "F", + 5: "S", + 6: "S", + }, + "short": { + 0: "Mo", + 1: "Tu", + 2: "We", + 3: "Th", + 4: "Fr", + 5: "Sa", + 6: "Su", + }, + "wide": { + 0: "Monday", + 1: "Tuesday", + 2: "Wednesday", + 3: "Thursday", + 4: "Friday", + 5: "Saturday", + 6: "Sunday", + }, + }, + "months": { + "abbreviated": { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sept", + 10: "Oct", + 11: "Nov", + 12: "Dec", + }, + "narrow": { + 1: "J", + 2: "F", + 3: "M", + 4: "A", + 5: "M", + 6: "J", + 7: "J", + 8: "A", + 9: "S", + 10: "O", + 11: "N", + 12: "D", + }, + "wide": { + 1: "January", + 2: "February", + 3: "March", + 4: "April", + 5: "May", + 6: "June", + 7: "July", + 8: "August", + 9: "September", + 10: "October", + 11: "November", + 12: "December", + }, + }, + "units": { + "year": { + "one": "{0} year", + "other": "{0} years", + }, + "month": { + "one": "{0} month", + "other": "{0} months", + }, + "week": { + "one": "{0} week", + "other": "{0} weeks", + }, + "day": { + "one": "{0} day", + "other": "{0} days", + }, + "hour": { + "one": "{0} hour", + "other": "{0} hours", + }, + "minute": { + "one": "{0} minute", + "other": "{0} minutes", + }, + "second": { + "one": "{0} second", + "other": "{0} seconds", + }, + "microsecond": { + "one": "{0} microsecond", + "other": "{0} microseconds", + }, + }, + "relative": { + "year": { + "future": { + "other": "in {0} years", + "one": "in {0} year", + }, + "past": { + "other": "{0} years ago", + "one": "{0} year ago", + }, + }, + "month": { + "future": { + "other": "in {0} months", + "one": "in {0} month", + }, + "past": { + "other": "{0} months ago", + "one": "{0} month ago", + }, + }, + "week": { + "future": { + "other": "in {0} weeks", + "one": "in {0} week", + }, + "past": { + "other": "{0} weeks ago", + "one": "{0} week ago", + }, + }, + "day": { + "future": { + "other": "in {0} days", + "one": "in {0} day", + }, + "past": { + "other": "{0} days ago", + "one": "{0} day ago", + }, + }, + "hour": { + "future": { + "other": "in {0} hours", + "one": "in {0} hour", + }, + "past": { + "other": "{0} hours ago", + "one": "{0} hour ago", + }, + }, + "minute": { + "future": { + "other": "in {0} minutes", + "one": "in {0} minute", + }, + "past": { + "other": "{0} minutes ago", + "one": "{0} minute ago", + }, + }, + "second": { + "future": { + "other": "in {0} seconds", + "one": "in {0} second", + }, + "past": { + "other": "{0} seconds ago", + "one": "{0} second ago", + }, + }, + }, + "day_periods": { + "midnight": "midnight", + "am": "am", + "noon": "noon", + "pm": "pm", + "morning1": "in the morning", + "afternoon1": "in the afternoon", + "evening1": "in the evening", + "night1": "at night", + }, + "week_data": { + "min_days": 4, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, + }, + "custom": custom_translations, +} diff --git a/pendulum/locales/en_us/__init__.py b/pendulum/locales/en_us/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pendulum/locales/en_us/custom.py b/pendulum/locales/en_us/custom.py new file mode 100644 index 00000000..943d8f8b --- /dev/null +++ b/pendulum/locales/en_us/custom.py @@ -0,0 +1,23 @@ +""" +en-us custom locale file. +""" + +translations = { + "units": {"few_second": "a few seconds"}, + # Relative time + "ago": "{} ago", + "from_now": "in {}", + "after": "{0} after", + "before": "{0} before", + # Ordinals + "ordinal": {"one": "st", "two": "nd", "few": "rd", "other": "th"}, + # Date formats + "date_formats": { + "LTS": "h:mm:ss A", + "LT": "h:mm A", + "L": "MM/DD/YYYY", + "LL": "MMMM D, YYYY", + "LLL": "MMMM D, YYYY h:mm A", + "LLLL": "dddd, MMMM D, YYYY h:mm A", + }, +} diff --git a/pendulum/locales/en_us/locale.py b/pendulum/locales/en_us/locale.py new file mode 100644 index 00000000..657c76f6 --- /dev/null +++ b/pendulum/locales/en_us/locale.py @@ -0,0 +1,238 @@ +from .custom import translations as custom_translations + + +""" +en-us locale file. + +It has been generated automatically and must not be modified directly. +""" + + +locale = { + "plural": lambda n: "one" + if ((n == n and ((n == 1))) and (0 == 0 and ((0 == 0)))) + else "other", + "ordinal": lambda n: "few" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 3))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 13)))) + ) + else "one" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 1))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 11)))) + ) + else "two" + if ( + ((n % 10) == (n % 10) and (((n % 10) == 2))) + and (not ((n % 100) == (n % 100) and (((n % 100) == 12)))) + ) + else "other", + "translations": { + "days": { + "abbreviated": { + 0: "Mon", + 1: "Tue", + 2: "Wed", + 3: "Thu", + 4: "Fri", + 5: "Sat", + 6: "Sun", + }, + "narrow": { + 0: "M", + 1: "T", + 2: "W", + 3: "T", + 4: "F", + 5: "S", + 6: "S", + }, + "short": { + 0: "Mo", + 1: "Tu", + 2: "We", + 3: "Th", + 4: "Fr", + 5: "Sa", + 6: "Su", + }, + "wide": { + 0: "Monday", + 1: "Tuesday", + 2: "Wednesday", + 3: "Thursday", + 4: "Friday", + 5: "Saturday", + 6: "Sunday", + }, + }, + "months": { + "abbreviated": { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + }, + "narrow": { + 1: "J", + 2: "F", + 3: "M", + 4: "A", + 5: "M", + 6: "J", + 7: "J", + 8: "A", + 9: "S", + 10: "O", + 11: "N", + 12: "D", + }, + "wide": { + 1: "January", + 2: "February", + 3: "March", + 4: "April", + 5: "May", + 6: "June", + 7: "July", + 8: "August", + 9: "September", + 10: "October", + 11: "November", + 12: "December", + }, + }, + "units": { + "year": { + "one": "{0} year", + "other": "{0} years", + }, + "month": { + "one": "{0} month", + "other": "{0} months", + }, + "week": { + "one": "{0} week", + "other": "{0} weeks", + }, + "day": { + "one": "{0} day", + "other": "{0} days", + }, + "hour": { + "one": "{0} hour", + "other": "{0} hours", + }, + "minute": { + "one": "{0} minute", + "other": "{0} minutes", + }, + "second": { + "one": "{0} second", + "other": "{0} seconds", + }, + "microsecond": { + "one": "{0} microsecond", + "other": "{0} microseconds", + }, + }, + "relative": { + "year": { + "future": { + "other": "in {0} years", + "one": "in {0} year", + }, + "past": { + "other": "{0} years ago", + "one": "{0} year ago", + }, + }, + "month": { + "future": { + "other": "in {0} months", + "one": "in {0} month", + }, + "past": { + "other": "{0} months ago", + "one": "{0} month ago", + }, + }, + "week": { + "future": { + "other": "in {0} weeks", + "one": "in {0} week", + }, + "past": { + "other": "{0} weeks ago", + "one": "{0} week ago", + }, + }, + "day": { + "future": { + "other": "in {0} days", + "one": "in {0} day", + }, + "past": { + "other": "{0} days ago", + "one": "{0} day ago", + }, + }, + "hour": { + "future": { + "other": "in {0} hours", + "one": "in {0} hour", + }, + "past": { + "other": "{0} hours ago", + "one": "{0} hour ago", + }, + }, + "minute": { + "future": { + "other": "in {0} minutes", + "one": "in {0} minute", + }, + "past": { + "other": "{0} minutes ago", + "one": "{0} minute ago", + }, + }, + "second": { + "future": { + "other": "in {0} seconds", + "one": "in {0} second", + }, + "past": { + "other": "{0} seconds ago", + "one": "{0} second ago", + }, + }, + }, + "day_periods": { + "midnight": "midnight", + "am": "AM", + "noon": "noon", + "pm": "PM", + "morning1": "in the morning", + "afternoon1": "in the afternoon", + "evening1": "in the evening", + "night1": "at night", + }, + "week_data": { + "min_days": 1, + "first_day": 6, + "weekend_start": 5, + "weekend_end": 6, + }, + }, + "custom": custom_translations, +} diff --git a/pendulum/locales/es/locale.py b/pendulum/locales/es/locale.py index edba4d38..09fa1441 100644 --- a/pendulum/locales/es/locale.py +++ b/pendulum/locales/es/locale.py @@ -14,24 +14,24 @@ "translations": { "days": { "abbreviated": { - 0: "dom.", - 1: "lun.", - 2: "mar.", - 3: "mié.", - 4: "jue.", - 5: "vie.", - 6: "sáb.", + 0: "lun.", + 1: "mar.", + 2: "mié.", + 3: "jue.", + 4: "vie.", + 5: "sáb.", + 6: "dom.", }, - "narrow": {0: "D", 1: "L", 2: "M", 3: "X", 4: "J", 5: "V", 6: "S"}, - "short": {0: "DO", 1: "LU", 2: "MA", 3: "MI", 4: "JU", 5: "VI", 6: "SA"}, + "narrow": {0: "L", 1: "M", 2: "X", 3: "J", 4: "V", 5: "S", 6: "D"}, + "short": {0: "LU", 1: "MA", 2: "MI", 3: "JU", 4: "VI", 5: "SA", 6: "DO"}, "wide": { - 0: "domingo", - 1: "lunes", - 2: "martes", - 3: "miércoles", - 4: "jueves", - 5: "viernes", - 6: "sábado", + 0: "lunes", + 1: "martes", + 2: "miércoles", + 3: "jueves", + 4: "viernes", + 5: "sábado", + 6: "domingo", }, }, "months": { @@ -136,6 +136,12 @@ "evening1": "de la tarde", "night1": "de la noche", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/fa/locale.py b/pendulum/locales/fa/locale.py index 32f8e5f3..43aff228 100644 --- a/pendulum/locales/fa/locale.py +++ b/pendulum/locales/fa/locale.py @@ -16,24 +16,24 @@ "translations": { "days": { "abbreviated": { - 0: "یکشنبه", - 1: "دوشنبه", - 2: "سه\u200cشنبه", - 3: "چهارشنبه", - 4: "پنجشنبه", - 5: "جمعه", - 6: "شنبه", + 0: "دوشنبه", + 1: "سه\u200cشنبه", + 2: "چهارشنبه", + 3: "پنجشنبه", + 4: "جمعه", + 5: "شنبه", + 6: "یکشنبه", }, - "narrow": {0: "ی", 1: "د", 2: "س", 3: "چ", 4: "پ", 5: "ج", 6: "ش"}, - "short": {0: "۱ش", 1: "۲ش", 2: "۳ش", 3: "۴ش", 4: "۵ش", 5: "ج", 6: "ش"}, + "narrow": {0: "د", 1: "س", 2: "چ", 3: "پ", 4: "ج", 5: "ش", 6: "ی"}, + "short": {0: "۲ش", 1: "۳ش", 2: "۴ش", 3: "۵ش", 4: "ج", 5: "ش", 6: "۱ش"}, "wide": { - 0: "یکشنبه", - 1: "دوشنبه", - 2: "سه\u200cشنبه", - 3: "چهارشنبه", - 4: "پنجشنبه", - 5: "جمعه", - 6: "شنبه", + 0: "دوشنبه", + 1: "سه\u200cشنبه", + 2: "چهارشنبه", + 3: "پنجشنبه", + 4: "جمعه", + 5: "شنبه", + 6: "یکشنبه", }, }, "months": { @@ -130,6 +130,12 @@ "evening1": "عصر", "night1": "شب", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/fo/locale.py b/pendulum/locales/fo/locale.py index 10319eaa..a13792a7 100644 --- a/pendulum/locales/fo/locale.py +++ b/pendulum/locales/fo/locale.py @@ -14,32 +14,32 @@ "translations": { "days": { "abbreviated": { - 0: "sun.", - 1: "mán.", - 2: "týs.", - 3: "mik.", - 4: "hós.", - 5: "frí.", - 6: "ley.", + 0: "mán.", + 1: "týs.", + 2: "mik.", + 3: "hós.", + 4: "frí.", + 5: "ley.", + 6: "sun.", }, - "narrow": {0: "S", 1: "M", 2: "T", 3: "M", 4: "H", 5: "F", 6: "L"}, + "narrow": {0: "M", 1: "T", 2: "M", 3: "H", 4: "F", 5: "L", 6: "S"}, "short": { - 0: "su.", - 1: "má.", - 2: "tý.", - 3: "mi.", - 4: "hó.", - 5: "fr.", - 6: "le.", + 0: "má.", + 1: "tý.", + 2: "mi.", + 3: "hó.", + 4: "fr.", + 5: "le.", + 6: "su.", }, "wide": { - 0: "sunnudagur", - 1: "mánadagur", - 2: "týsdagur", - 3: "mikudagur", - 4: "hósdagur", - 5: "fríggjadagur", - 6: "leygardagur", + 0: "mánadagur", + 1: "týsdagur", + 2: "mikudagur", + 3: "hósdagur", + 4: "fríggjadagur", + 5: "leygardagur", + 6: "sunnudagur", }, }, "months": { @@ -127,6 +127,12 @@ }, }, "day_periods": {"am": "AM", "pm": "PM"}, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/fr/locale.py b/pendulum/locales/fr/locale.py index 8855d53c..241ae987 100644 --- a/pendulum/locales/fr/locale.py +++ b/pendulum/locales/fr/locale.py @@ -14,24 +14,24 @@ "translations": { "days": { "abbreviated": { - 0: "dim.", - 1: "lun.", - 2: "mar.", - 3: "mer.", - 4: "jeu.", - 5: "ven.", - 6: "sam.", + 0: "lun.", + 1: "mar.", + 2: "mer.", + 3: "jeu.", + 4: "ven.", + 5: "sam.", + 6: "dim.", }, - "narrow": {0: "D", 1: "L", 2: "M", 3: "M", 4: "J", 5: "V", 6: "S"}, - "short": {0: "di", 1: "lu", 2: "ma", 3: "me", 4: "je", 5: "ve", 6: "sa"}, + "narrow": {0: "L", 1: "M", 2: "M", 3: "J", 4: "V", 5: "S", 6: "D"}, + "short": {0: "lu", 1: "ma", 2: "me", 3: "je", 4: "ve", 5: "sa", 6: "di"}, "wide": { - 0: "dimanche", - 1: "lundi", - 2: "mardi", - 3: "mercredi", - 4: "jeudi", - 5: "vendredi", - 6: "samedi", + 0: "lundi", + 1: "mardi", + 2: "mercredi", + 3: "jeudi", + 4: "vendredi", + 5: "samedi", + 6: "dimanche", }, }, "months": { @@ -128,6 +128,12 @@ "evening1": "du soir", "night1": "de nuit", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/he/locale.py b/pendulum/locales/he/locale.py index 457c1019..9e8a8e00 100644 --- a/pendulum/locales/he/locale.py +++ b/pendulum/locales/he/locale.py @@ -23,40 +23,40 @@ "translations": { "days": { "abbreviated": { - 0: "יום א׳", - 1: "יום ב׳", - 2: "יום ג׳", - 3: "יום ד׳", - 4: "יום ה׳", - 5: "יום ו׳", - 6: "שבת", + 0: "יום ב׳", + 1: "יום ג׳", + 2: "יום ד׳", + 3: "יום ה׳", + 4: "יום ו׳", + 5: "שבת", + 6: "יום א׳", }, "narrow": { - 0: "א׳", - 1: "ב׳", - 2: "ג׳", - 3: "ד׳", - 4: "ה׳", - 5: "ו׳", - 6: "ש׳", + 0: "ב׳", + 1: "ג׳", + 2: "ד׳", + 3: "ה׳", + 4: "ו׳", + 5: "ש׳", + 6: "א׳", }, "short": { - 0: "א׳", - 1: "ב׳", - 2: "ג׳", - 3: "ד׳", - 4: "ה׳", - 5: "ו׳", - 6: "ש׳", + 0: "ב׳", + 1: "ג׳", + 2: "ד׳", + 3: "ה׳", + 4: "ו׳", + 5: "ש׳", + 6: "א׳", }, "wide": { - 0: "יום ראשון", - 1: "יום שני", - 2: "יום שלישי", - 3: "יום רביעי", - 4: "יום חמישי", - 5: "יום שישי", - 6: "יום שבת", + 0: "יום שני", + 1: "יום שלישי", + 2: "יום רביעי", + 3: "יום חמישי", + 4: "יום שישי", + 5: "יום שבת", + 6: "יום ראשון", }, }, "months": { @@ -264,6 +264,12 @@ "night1": "בלילה", "night2": "לפנות בוקר", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/id/locale.py b/pendulum/locales/id/locale.py index bc994ce4..fff8a934 100644 --- a/pendulum/locales/id/locale.py +++ b/pendulum/locales/id/locale.py @@ -14,32 +14,32 @@ "translations": { "days": { "abbreviated": { - 0: "Min", - 1: "Sen", - 2: "Sel", - 3: "Rab", - 4: "Kam", - 5: "Jum", - 6: "Sab", + 0: "Sen", + 1: "Sel", + 2: "Rab", + 3: "Kam", + 4: "Jum", + 5: "Sab", + 6: "Min", }, - "narrow": {0: "M", 1: "S", 2: "S", 3: "R", 4: "K", 5: "J", 6: "S"}, + "narrow": {0: "S", 1: "S", 2: "R", 3: "K", 4: "J", 5: "S", 6: "M"}, "short": { - 0: "Min", - 1: "Sen", - 2: "Sel", - 3: "Rab", - 4: "Kam", - 5: "Jum", - 6: "Sab", + 0: "Sen", + 1: "Sel", + 2: "Rab", + 3: "Kam", + 4: "Jum", + 5: "Sab", + 6: "Min", }, "wide": { - 0: "Minggu", - 1: "Senin", - 2: "Selasa", - 3: "Rabu", - 4: "Kamis", - 5: "Jumat", - 6: "Sabtu", + 0: "Senin", + 1: "Selasa", + 2: "Rabu", + 3: "Kamis", + 4: "Jumat", + 5: "Sabtu", + 6: "Minggu", }, }, "months": { @@ -136,6 +136,12 @@ "evening1": "sore", "night1": "malam", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/it/locale.py b/pendulum/locales/it/locale.py index bb3fdcf6..f2ebbfd2 100644 --- a/pendulum/locales/it/locale.py +++ b/pendulum/locales/it/locale.py @@ -18,32 +18,32 @@ "translations": { "days": { "abbreviated": { - 0: "dom", - 1: "lun", - 2: "mar", - 3: "mer", - 4: "gio", - 5: "ven", - 6: "sab", + 0: "lun", + 1: "mar", + 2: "mer", + 3: "gio", + 4: "ven", + 5: "sab", + 6: "dom", }, - "narrow": {0: "D", 1: "L", 2: "M", 3: "M", 4: "G", 5: "V", 6: "S"}, + "narrow": {0: "L", 1: "M", 2: "M", 3: "G", 4: "V", 5: "S", 6: "D"}, "short": { - 0: "dom", - 1: "lun", - 2: "mar", - 3: "mer", - 4: "gio", - 5: "ven", - 6: "sab", + 0: "lun", + 1: "mar", + 2: "mer", + 3: "gio", + 4: "ven", + 5: "sab", + 6: "dom", }, "wide": { - 0: "domenica", - 1: "lunedì", - 2: "martedì", - 3: "mercoledì", - 4: "giovedì", - 5: "venerdì", - 6: "sabato", + 0: "lunedì", + 1: "martedì", + 2: "mercoledì", + 3: "giovedì", + 4: "venerdì", + 5: "sabato", + 6: "domenica", }, }, "months": { @@ -140,6 +140,12 @@ "evening1": "di sera", "night1": "di notte", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/ja/locale.py b/pendulum/locales/ja/locale.py index 574d2ec0..e6f5cfd4 100644 --- a/pendulum/locales/ja/locale.py +++ b/pendulum/locales/ja/locale.py @@ -14,40 +14,40 @@ "translations": { "days": { "abbreviated": { - 0: "日", - 1: "月", - 2: "火", - 3: "水", - 4: "木", - 5: "金", - 6: "土", + 0: "月", + 1: "火", + 2: "水", + 3: "木", + 4: "金", + 5: "土", + 6: "日", }, "narrow": { - 0: "日", - 1: "月", - 2: "火", - 3: "水", - 4: "木", - 5: "金", - 6: "土", + 0: "月", + 1: "火", + 2: "水", + 3: "木", + 4: "金", + 5: "土", + 6: "日", }, "short": { - 0: "日", - 1: "月", - 2: "火", - 3: "水", - 4: "木", - 5: "金", - 6: "土", + 0: "月", + 1: "火", + 2: "水", + 3: "木", + 4: "金", + 5: "土", + 6: "日", }, "wide": { - 0: "日曜日", - 1: "月曜日", - 2: "火曜日", - 3: "水曜日", - 4: "木曜日", - 5: "金曜日", - 6: "土曜日", + 0: "月曜日", + 1: "火曜日", + 2: "水曜日", + 3: "木曜日", + 4: "金曜日", + 5: "土曜日", + 6: "日曜日", }, }, "months": { @@ -189,6 +189,12 @@ "night1": "夜", "night2": "夜中", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/ko/locale.py b/pendulum/locales/ko/locale.py index 0f5a3462..8ca36eb9 100644 --- a/pendulum/locales/ko/locale.py +++ b/pendulum/locales/ko/locale.py @@ -13,17 +13,17 @@ "ordinal": lambda n: "other", "translations": { "days": { - "abbreviated": {0: "일", 1: "월", 2: "화", 3: "수", 4: "목", 5: "금", 6: "토"}, - "narrow": {0: "일", 1: "월", 2: "화", 3: "수", 4: "목", 5: "금", 6: "토"}, - "short": {0: "일", 1: "월", 2: "화", 3: "수", 4: "목", 5: "금", 6: "토"}, + "abbreviated": {0: "월", 1: "화", 2: "수", 3: "목", 4: "금", 5: "토", 6: "일"}, + "narrow": {0: "월", 1: "화", 2: "수", 3: "목", 4: "금", 5: "토", 6: "일"}, + "short": {0: "월", 1: "화", 2: "수", 3: "목", 4: "금", 5: "토", 6: "일"}, "wide": { - 0: "일요일", - 1: "월요일", - 2: "화요일", - 3: "수요일", - 4: "목요일", - 5: "금요일", - 6: "토요일", + 0: "월요일", + 1: "화요일", + 2: "수요일", + 3: "목요일", + 4: "금요일", + 5: "토요일", + 6: "일요일", }, }, "months": { @@ -100,6 +100,12 @@ "evening1": "저녁", "night1": "밤", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/lt/locale.py b/pendulum/locales/lt/locale.py index fb017efa..aeae21ec 100644 --- a/pendulum/locales/lt/locale.py +++ b/pendulum/locales/lt/locale.py @@ -26,24 +26,24 @@ "translations": { "days": { "abbreviated": { - 0: "sk", - 1: "pr", - 2: "an", - 3: "tr", - 4: "kt", - 5: "pn", - 6: "št", - }, - "narrow": {0: "S", 1: "P", 2: "A", 3: "T", 4: "K", 5: "P", 6: "Š"}, - "short": {0: "Sk", 1: "Pr", 2: "An", 3: "Tr", 4: "Kt", 5: "Pn", 6: "Št"}, + 0: "pr", + 1: "an", + 2: "tr", + 3: "kt", + 4: "pn", + 5: "št", + 6: "sk", + }, + "narrow": {0: "P", 1: "A", 2: "T", 3: "K", 4: "P", 5: "Š", 6: "S"}, + "short": {0: "Pr", 1: "An", 2: "Tr", 3: "Kt", 4: "Pn", 5: "Št", 6: "Sk"}, "wide": { - 0: "sekmadienis", - 1: "pirmadienis", - 2: "antradienis", - 3: "trečiadienis", - 4: "ketvirtadienis", - 5: "penktadienis", - 6: "šeštadienis", + 0: "pirmadienis", + 1: "antradienis", + 2: "trečiadienis", + 3: "ketvirtadienis", + 4: "penktadienis", + 5: "šeštadienis", + 6: "sekmadienis", }, }, "months": { @@ -250,6 +250,12 @@ "evening1": "vakaras", "night1": "naktis", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/nb/locale.py b/pendulum/locales/nb/locale.py index c8297a86..efb03b52 100644 --- a/pendulum/locales/nb/locale.py +++ b/pendulum/locales/nb/locale.py @@ -14,32 +14,32 @@ "translations": { "days": { "abbreviated": { - 0: "søn.", - 1: "man.", - 2: "tir.", - 3: "ons.", - 4: "tor.", - 5: "fre.", - 6: "lør.", + 0: "man.", + 1: "tir.", + 2: "ons.", + 3: "tor.", + 4: "fre.", + 5: "lør.", + 6: "søn.", }, - "narrow": {0: "S", 1: "M", 2: "T", 3: "O", 4: "T", 5: "F", 6: "L"}, + "narrow": {0: "M", 1: "T", 2: "O", 3: "T", 4: "F", 5: "L", 6: "S"}, "short": { - 0: "sø.", - 1: "ma.", - 2: "ti.", - 3: "on.", - 4: "to.", - 5: "fr.", - 6: "lø.", + 0: "ma.", + 1: "ti.", + 2: "on.", + 3: "to.", + 4: "fr.", + 5: "lø.", + 6: "sø.", }, "wide": { - 0: "søndag", - 1: "mandag", - 2: "tirsdag", - 3: "onsdag", - 4: "torsdag", - 5: "fredag", - 6: "lørdag", + 0: "mandag", + 1: "tirsdag", + 2: "onsdag", + 3: "torsdag", + 4: "fredag", + 5: "lørdag", + 6: "søndag", }, }, "months": { @@ -145,6 +145,12 @@ "evening1": "kvelden", "night1": "natten", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/nl/locale.py b/pendulum/locales/nl/locale.py index cb1570d7..e1f498d8 100644 --- a/pendulum/locales/nl/locale.py +++ b/pendulum/locales/nl/locale.py @@ -16,24 +16,24 @@ "translations": { "days": { "abbreviated": { - 0: "zo", - 1: "ma", - 2: "di", - 3: "wo", - 4: "do", - 5: "vr", - 6: "za", + 0: "ma", + 1: "di", + 2: "wo", + 3: "do", + 4: "vr", + 5: "za", + 6: "zo", }, - "narrow": {0: "Z", 1: "M", 2: "D", 3: "W", 4: "D", 5: "V", 6: "Z"}, - "short": {0: "zo", 1: "ma", 2: "di", 3: "wo", 4: "do", 5: "vr", 6: "za"}, + "narrow": {0: "M", 1: "D", 2: "W", 3: "D", 4: "V", 5: "Z", 6: "Z"}, + "short": {0: "ma", 1: "di", 2: "wo", 3: "do", 4: "vr", 5: "za", 6: "zo"}, "wide": { - 0: "zondag", - 1: "maandag", - 2: "dinsdag", - 3: "woensdag", - 4: "donderdag", - 5: "vrijdag", - 6: "zaterdag", + 0: "maandag", + 1: "dinsdag", + 2: "woensdag", + 3: "donderdag", + 4: "vrijdag", + 5: "zaterdag", + 6: "zondag", }, }, "months": { @@ -128,6 +128,12 @@ "afternoon1": "‘s middags", "evening1": "‘s avonds", "night1": "‘s nachts", + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, }, "custom": custom_translations, diff --git a/pendulum/locales/nn/locale.py b/pendulum/locales/nn/locale.py index eb46e1de..d6565b13 100644 --- a/pendulum/locales/nn/locale.py +++ b/pendulum/locales/nn/locale.py @@ -14,32 +14,32 @@ "translations": { "days": { "abbreviated": { - 0: "søn.", - 1: "mån.", - 2: "tys.", - 3: "ons.", - 4: "tor.", - 5: "fre.", - 6: "lau.", + 0: "mån.", + 1: "tys.", + 2: "ons.", + 3: "tor.", + 4: "fre.", + 5: "lau.", + 6: "søn.", }, - "narrow": {0: "S", 1: "M", 2: "T", 3: "O", 4: "T", 5: "F", 6: "L"}, + "narrow": {0: "M", 1: "T", 2: "O", 3: "T", 4: "F", 5: "L", 6: "S"}, "short": { - 0: "sø.", - 1: "må.", - 2: "ty.", - 3: "on.", - 4: "to.", - 5: "fr.", - 6: "la.", + 0: "må.", + 1: "ty.", + 2: "on.", + 3: "to.", + 4: "fr.", + 5: "la.", + 6: "sø.", }, "wide": { - 0: "søndag", - 1: "måndag", - 2: "tysdag", - 3: "onsdag", - 4: "torsdag", - 5: "fredag", - 6: "laurdag", + 0: "måndag", + 1: "tysdag", + 2: "onsdag", + 3: "torsdag", + 4: "fredag", + 5: "laurdag", + 6: "søndag", }, }, "months": { @@ -136,6 +136,12 @@ }, }, "day_periods": {"am": "formiddag", "pm": "ettermiddag"}, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/pl/locale.py b/pendulum/locales/pl/locale.py index bf6af102..0f1943e7 100644 --- a/pendulum/locales/pl/locale.py +++ b/pendulum/locales/pl/locale.py @@ -41,32 +41,32 @@ "translations": { "days": { "abbreviated": { - 0: "niedz.", - 1: "pon.", - 2: "wt.", - 3: "śr.", - 4: "czw.", - 5: "pt.", - 6: "sob.", + 0: "pon.", + 1: "wt.", + 2: "śr.", + 3: "czw.", + 4: "pt.", + 5: "sob.", + 6: "niedz.", }, - "narrow": {0: "n", 1: "p", 2: "w", 3: "ś", 4: "c", 5: "p", 6: "s"}, + "narrow": {0: "p", 1: "w", 2: "ś", 3: "c", 4: "p", 5: "s", 6: "n"}, "short": { - 0: "nie", - 1: "pon", - 2: "wto", - 3: "śro", - 4: "czw", - 5: "pią", - 6: "sob", + 0: "pon", + 1: "wto", + 2: "śro", + 3: "czw", + 4: "pią", + 5: "sob", + 6: "nie", }, "wide": { - 0: "niedziela", - 1: "poniedziałek", - 2: "wtorek", - 3: "środa", - 4: "czwartek", - 5: "piątek", - 6: "sobota", + 0: "poniedziałek", + 1: "wtorek", + 2: "środa", + 3: "czwartek", + 4: "piątek", + 5: "sobota", + 6: "niedziela", }, }, "months": { @@ -274,6 +274,12 @@ "evening1": "wieczorem", "night1": "w nocy", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/pt_br/locale.py b/pendulum/locales/pt_br/locale.py index 742c41fe..4bd4feb8 100644 --- a/pendulum/locales/pt_br/locale.py +++ b/pendulum/locales/pt_br/locale.py @@ -16,32 +16,32 @@ "translations": { "days": { "abbreviated": { - 0: "dom", - 1: "seg", - 2: "ter", - 3: "qua", - 4: "qui", - 5: "sex", - 6: "sáb", + 0: "seg", + 1: "ter", + 2: "qua", + 3: "qui", + 4: "sex", + 5: "sáb", + 6: "dom", }, - "narrow": {0: "D", 1: "S", 2: "T", 3: "Q", 4: "Q", 5: "S", 6: "S"}, + "narrow": {0: "S", 1: "T", 2: "Q", 3: "Q", 4: "S", 5: "S", 6: "D"}, "short": { - 0: "dom", - 1: "seg", - 2: "ter", - 3: "qua", - 4: "qui", - 5: "sex", - 6: "sáb", + 0: "seg", + 1: "ter", + 2: "qua", + 3: "qui", + 4: "sex", + 5: "sáb", + 6: "dom", }, "wide": { - 0: "domingo", - 1: "segunda-feira", - 2: "terça-feira", - 3: "quarta-feira", - 4: "quinta-feira", - 5: "sexta-feira", - 6: "sábado", + 0: "segunda-feira", + 1: "terça-feira", + 2: "quarta-feira", + 3: "quinta-feira", + 4: "sexta-feira", + 5: "sábado", + 6: "domingo", }, }, "months": { @@ -138,6 +138,12 @@ "evening1": "da noite", "night1": "da madrugada", }, + "week_data": { + "min_days": 1, + "first_day": 6, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/ru/locale.py b/pendulum/locales/ru/locale.py index 3736e0b1..04154672 100644 --- a/pendulum/locales/ru/locale.py +++ b/pendulum/locales/ru/locale.py @@ -41,24 +41,24 @@ "translations": { "days": { "abbreviated": { - 0: "вс", - 1: "пн", - 2: "вт", - 3: "ср", - 4: "чт", - 5: "пт", - 6: "сб", + 0: "пн", + 1: "вт", + 2: "ср", + 3: "чт", + 4: "пт", + 5: "сб", + 6: "вс", }, - "narrow": {0: "вс", 1: "пн", 2: "вт", 3: "ср", 4: "чт", 5: "пт", 6: "сб"}, - "short": {0: "вс", 1: "пн", 2: "вт", 3: "ср", 4: "чт", 5: "пт", 6: "сб"}, + "narrow": {0: "пн", 1: "вт", 2: "ср", 3: "чт", 4: "пт", 5: "сб", 6: "вс"}, + "short": {0: "пн", 1: "вт", 2: "ср", 3: "чт", 4: "пт", 5: "сб", 6: "вс"}, "wide": { - 0: "воскресенье", - 1: "понедельник", - 2: "вторник", - 3: "среда", - 4: "четверг", - 5: "пятница", - 6: "суббота", + 0: "понедельник", + 1: "вторник", + 2: "среда", + 3: "четверг", + 4: "пятница", + 5: "суббота", + 6: "воскресенье", }, }, "months": { @@ -265,6 +265,12 @@ "evening1": "вечера", "night1": "ночи", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/sk/locale.py b/pendulum/locales/sk/locale.py index 8d3459ff..e3caee1d 100644 --- a/pendulum/locales/sk/locale.py +++ b/pendulum/locales/sk/locale.py @@ -20,40 +20,40 @@ "translations": { "days": { "abbreviated": { - 0: "ne", - 1: "po", - 2: "ut", - 3: "st", - 4: "št", - 5: "pi", - 6: "so", + 0: "po", + 1: "ut", + 2: "st", + 3: "št", + 4: "pi", + 5: "so", + 6: "ne", }, "narrow": { - 0: "n", - 1: "p", - 2: "u", - 3: "s", - 4: "š", - 5: "p", - 6: "s", + 0: "p", + 1: "u", + 2: "s", + 3: "š", + 4: "p", + 5: "s", + 6: "n", }, "short": { - 0: "ne", - 1: "po", - 2: "ut", - 3: "st", - 4: "št", - 5: "pi", - 6: "so", + 0: "po", + 1: "ut", + 2: "st", + 3: "št", + 4: "pi", + 5: "so", + 6: "ne", }, "wide": { - 0: "nedeľa", - 1: "pondelok", - 2: "utorok", - 3: "streda", - 4: "štvrtok", - 5: "piatok", - 6: "sobota", + 0: "pondelok", + 1: "utorok", + 2: "streda", + 3: "štvrtok", + 4: "piatok", + 5: "sobota", + 6: "nedeľa", }, }, "months": { @@ -261,6 +261,12 @@ "evening1": "večer", "night1": "v noci", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/sv/locale.py b/pendulum/locales/sv/locale.py index 5b74a6e1..457acf23 100644 --- a/pendulum/locales/sv/locale.py +++ b/pendulum/locales/sv/locale.py @@ -21,40 +21,40 @@ "translations": { "days": { "abbreviated": { - 0: "sön", - 1: "mån", - 2: "tis", - 3: "ons", - 4: "tors", - 5: "fre", - 6: "lör", + 0: "mån", + 1: "tis", + 2: "ons", + 3: "tors", + 4: "fre", + 5: "lör", + 6: "sön", }, "narrow": { - 0: "S", - 1: "M", - 2: "T", - 3: "O", - 4: "T", - 5: "F", - 6: "L", + 0: "M", + 1: "T", + 2: "O", + 3: "T", + 4: "F", + 5: "L", + 6: "S", }, "short": { - 0: "sö", - 1: "må", - 2: "ti", - 3: "on", - 4: "to", - 5: "fr", - 6: "lö", + 0: "må", + 1: "ti", + 2: "on", + 3: "to", + 4: "fr", + 5: "lö", + 6: "sö", }, "wide": { - 0: "söndag", - 1: "måndag", - 2: "tisdag", - 3: "onsdag", - 4: "torsdag", - 5: "fredag", - 6: "lördag", + 0: "måndag", + 1: "tisdag", + 2: "onsdag", + 3: "torsdag", + 4: "fredag", + 5: "lördag", + 6: "söndag", }, }, "months": { @@ -217,6 +217,12 @@ "evening1": "på kvällen", "night1": "på natten", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/tr/locale.py b/pendulum/locales/tr/locale.py index 1806df17..8b605345 100644 --- a/pendulum/locales/tr/locale.py +++ b/pendulum/locales/tr/locale.py @@ -14,40 +14,40 @@ "translations": { "days": { "abbreviated": { - 0: "Paz", - 1: "Pzt", - 2: "Sal", - 3: "Çar", - 4: "Per", - 5: "Cum", - 6: "Cmt", + 0: "Pzt", + 1: "Sal", + 2: "Çar", + 3: "Per", + 4: "Cum", + 5: "Cmt", + 6: "Paz", }, "narrow": { 0: "P", - 1: "P", - 2: "S", - 3: "Ç", - 4: "P", + 1: "S", + 2: "Ç", + 3: "P", + 4: "C", 5: "C", - 6: "C", + 6: "P", }, "short": { - 0: "Pa", - 1: "Pt", - 2: "Sa", - 3: "Ça", - 4: "Pe", - 5: "Cu", - 6: "Ct", + 0: "Pt", + 1: "Sa", + 2: "Ça", + 3: "Pe", + 4: "Cu", + 5: "Ct", + 6: "Pa", }, "wide": { - 0: "Pazar", - 1: "Pazartesi", - 2: "Salı", - 3: "Çarşamba", - 4: "Perşembe", - 5: "Cuma", - 6: "Cumartesi", + 0: "Pazartesi", + 1: "Salı", + 2: "Çarşamba", + 3: "Perşembe", + 4: "Cuma", + 5: "Cumartesi", + 6: "Pazar", }, }, "months": { @@ -212,6 +212,12 @@ "evening1": "akşam", "night1": "gece", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/pendulum/locales/zh/locale.py b/pendulum/locales/zh/locale.py index 2df477f9..30b353d3 100644 --- a/pendulum/locales/zh/locale.py +++ b/pendulum/locales/zh/locale.py @@ -14,24 +14,24 @@ "translations": { "days": { "abbreviated": { - 0: "周日", - 1: "周一", - 2: "周二", - 3: "周三", - 4: "周四", - 5: "周五", - 6: "周六", + 0: "周一", + 1: "周二", + 2: "周三", + 3: "周四", + 4: "周五", + 5: "周六", + 6: "周日", }, - "narrow": {0: "日", 1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六"}, - "short": {0: "周日", 1: "周一", 2: "周二", 3: "周三", 4: "周四", 5: "周五", 6: "周六"}, + "narrow": {0: "一", 1: "二", 2: "三", 3: "四", 4: "五", 5: "六", 6: "日"}, + "short": {0: "周一", 1: "周二", 2: "周三", 3: "周四", 4: "周五", 5: "周六", 6: "周日"}, "wide": { - 0: "星期日", - 1: "星期一", - 2: "星期二", - 3: "星期三", - 4: "星期四", - 5: "星期五", - 6: "星期六", + 0: "星期一", + 1: "星期二", + 2: "星期三", + 3: "星期四", + 4: "星期五", + 5: "星期六", + 6: "星期日", }, }, "months": { @@ -108,6 +108,12 @@ "evening1": "晚上", "night1": "凌晨", }, + "week_data": { + "min_days": 1, + "first_day": 0, + "weekend_start": 5, + "weekend_end": 6, + }, }, "custom": custom_translations, } diff --git a/poetry.lock b/poetry.lock index 4addbfb4..68f84bda 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1195,4 +1195,4 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "658e22a0828244e01d1639cbacfbaa84a6ad345aade89e5e28722fb39401db37" +content-hash = "6110c4ae04517ea55be06ed75b9d4bbde83798bba6b365ac01a1b3919230c5b7" diff --git a/pyproject.toml b/pyproject.toml index f5c5e715..58f6547e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ python-dateutil = "^2.6" time-machine = { version = "^2.6.0", markers = "implementation_name != 'pypy'" } tzdata = ">=2020.1" importlib-resources = { version = "^5.9.0", python = ">=3.7,<3.9" } +cleo = "^2.0.1" [tool.poetry.group.test.dependencies] pytest = "^7.1.2" @@ -92,6 +93,7 @@ ignore = [ "B904", # use 'raise ... from err' "B905", # use explicit 'strict=' parameter with 'zip()' "N818", # Exception name should be named with an Error suffix + "RUF001", ] extend-exclude = [ # External to the project's coding standards: diff --git a/tests/conftest.py b/tests/conftest.py index 8f0e6b93..99f4b93a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,8 +19,8 @@ def setup() -> Iterator[None]: pendulum.set_locale("en") pendulum.set_local_timezone() - pendulum.week_starts_at(pendulum.MONDAY) - pendulum.week_ends_at(pendulum.SUNDAY) + pendulum.week_starts_at(pendulum.WeekDay.MONDAY) + pendulum.week_ends_at(pendulum.WeekDay.SUNDAY) def assert_datetime( diff --git a/tests/date/test_day_of_week_modifiers.py b/tests/date/test_day_of_week_modifiers.py index 55aba551..03630967 100644 --- a/tests/date/test_day_of_week_modifiers.py +++ b/tests/date/test_day_of_week_modifiers.py @@ -49,7 +49,7 @@ def test_next_monday(): def test_next_saturday(): - d = pendulum.date(1975, 5, 21).next(6) + d = pendulum.date(1975, 5, 21).next(5) assert_date(d, 1975, 5, 24) @@ -71,7 +71,7 @@ def test_previous_monday(): def test_previous_saturday(): - d = pendulum.date(1975, 5, 21).previous(6) + d = pendulum.date(1975, 5, 21).previous(5) assert_date(d, 1975, 5, 17) @@ -93,7 +93,7 @@ def test_first_wednesday_of_month(): def test_first_friday_of_month(): - d = pendulum.date(1975, 11, 21).first_of("month", 5) + d = pendulum.date(1975, 11, 21).first_of("month", 4) assert_date(d, 1975, 11, 7) @@ -108,7 +108,7 @@ def test_last_tuesday_of_month(): def test_last_friday_of_month(): - d = pendulum.date(1975, 12, 5).last_of("month", 5) + d = pendulum.date(1975, 12, 5).last_of("month", 4) assert_date(d, 1975, 12, 26) @@ -139,7 +139,7 @@ def test_2nd_monday_of_month(): def test_3rd_wednesday_of_month(): - d = pendulum.date(1975, 12, 5).nth_of("month", 3, 3) + d = pendulum.date(1975, 12, 5).nth_of("month", 3, 2) assert_date(d, 1975, 12, 17) @@ -155,7 +155,7 @@ def test_first_wednesday_of_quarter(): def test_first_friday_of_quarter(): - d = pendulum.date(1975, 11, 21).first_of("quarter", 5) + d = pendulum.date(1975, 11, 21).first_of("quarter", 4) assert_date(d, 1975, 10, 3) @@ -215,7 +215,7 @@ def test_2nd_monday_of_quarter(): def test_3rd_wednesday_of_quarter(): - d = pendulum.date(1975, 8, 5).nth_of("quarter", 3, 3) + d = pendulum.date(1975, 8, 5).nth_of("quarter", 3, 2) assert_date(d, 1975, 7, 16) @@ -230,7 +230,7 @@ def test_first_wednesday_of_year(): def test_first_friday_of_year(): - d = pendulum.date(1975, 11, 21).first_of("year", 5) + d = pendulum.date(1975, 11, 21).first_of("year", 4) assert_date(d, 1975, 1, 3) @@ -245,7 +245,7 @@ def test_last_tuesday_of_year(): def test_last_friday_of_year(): - d = pendulum.date(1975, 8, 5).last_of("year", 5) + d = pendulum.date(1975, 8, 5).last_of("year", 4) assert_date(d, 1975, 12, 26) diff --git a/tests/datetime/test_day_of_week_modifiers.py b/tests/datetime/test_day_of_week_modifiers.py index 46de84e7..eb4bc4f7 100644 --- a/tests/datetime/test_day_of_week_modifiers.py +++ b/tests/datetime/test_day_of_week_modifiers.py @@ -49,7 +49,7 @@ def test_next_monday(): def test_next_saturday(): - d = pendulum.datetime(1975, 5, 21).next(6) + d = pendulum.datetime(1975, 5, 21).next(5) assert_datetime(d, 1975, 5, 24, 0, 0, 0) @@ -79,7 +79,7 @@ def test_previous_monday(): def test_previous_saturday(): - d = pendulum.datetime(1975, 5, 21).previous(6) + d = pendulum.datetime(1975, 5, 21).previous(5) assert_datetime(d, 1975, 5, 17, 0, 0, 0) @@ -109,7 +109,7 @@ def test_first_wednesday_of_month(): def test_first_friday_of_month(): - d = pendulum.datetime(1975, 11, 21).first_of("month", 5) + d = pendulum.datetime(1975, 11, 21).first_of("month", 4) assert_datetime(d, 1975, 11, 7, 0, 0, 0) @@ -124,7 +124,7 @@ def test_last_tuesday_of_month(): def test_last_friday_of_month(): - d = pendulum.datetime(1975, 12, 5).last_of("month", 5) + d = pendulum.datetime(1975, 12, 5).last_of("month", 4) assert_datetime(d, 1975, 12, 26, 0, 0, 0) @@ -155,7 +155,7 @@ def test_2nd_monday_of_month(): def test_3rd_wednesday_of_month(): - d = pendulum.datetime(1975, 12, 5).nth_of("month", 3, 3) + d = pendulum.datetime(1975, 12, 5).nth_of("month", 3, 2) assert_datetime(d, 1975, 12, 17, 0, 0, 0) @@ -171,7 +171,7 @@ def test_first_wednesday_of_quarter(): def test_first_friday_of_quarter(): - d = pendulum.datetime(1975, 11, 21).first_of("quarter", 5) + d = pendulum.datetime(1975, 11, 21).first_of("quarter", 4) assert_datetime(d, 1975, 10, 3, 0, 0, 0) @@ -231,7 +231,7 @@ def test_2nd_monday_of_quarter(): def test_3rd_wednesday_of_quarter(): - d = pendulum.datetime(1975, 8, 5).nth_of("quarter", 3, 3) + d = pendulum.datetime(1975, 8, 5).nth_of("quarter", 3, 2) assert_datetime(d, 1975, 7, 16, 0, 0, 0) @@ -246,7 +246,7 @@ def test_first_wednesday_of_year(): def test_first_friday_of_year(): - d = pendulum.datetime(1975, 11, 21).first_of("year", 5) + d = pendulum.datetime(1975, 11, 21).first_of("year", 4) assert_datetime(d, 1975, 1, 3, 0, 0, 0) @@ -261,7 +261,7 @@ def test_last_tuesday_of_year(): def test_last_friday_of_year(): - d = pendulum.datetime(1975, 8, 5).last_of("year", 5) + d = pendulum.datetime(1975, 8, 5).last_of("year", 4) assert_datetime(d, 1975, 12, 26, 0, 0, 0) diff --git a/tests/datetime/test_from_format.py b/tests/datetime/test_from_format.py index 1d5e24ae..184c0a02 100644 --- a/tests/datetime/test_from_format.py +++ b/tests/datetime/test_from_format.py @@ -99,7 +99,8 @@ def test_from_format_with_invalid_padded_day(): ("Monday", "dddd", "2018-01-29T00:00:00+00:00", "2018-02-02"), ("Mon", "ddd", "2018-01-29T00:00:00+00:00", "2018-02-02"), ("Mo", "dd", "2018-01-29T00:00:00+00:00", "2018-02-02"), - ("0", "d", "2018-02-04T00:00:00+00:00", "2018-02-02"), + ("0", "d", "2018-01-29T00:00:00+00:00", "2018-02-02"), + ("6", "d", "2018-02-04T00:00:00+00:00", "2018-02-02"), ("1", "E", "2018-01-29T00:00:00+00:00", "2018-02-02"), ("March", "MMMM", "2018-03-01T00:00:00+00:00", "2018-02-02"), ("Mar", "MMM", "2018-03-01T00:00:00+00:00", "2018-02-02"), diff --git a/tests/formatting/test_formatter.py b/tests/formatting/test_formatter.py index 76c7a7ff..4c4b0088 100644 --- a/tests/formatting/test_formatter.py +++ b/tests/formatting/test_formatter.py @@ -113,6 +113,20 @@ def test_day_of_week(): assert f.format(d, "do") == "0th" +def test_localized_day_of_week(): + f = Formatter() + d = pendulum.datetime(2016, 8, 28) + assert f.format(d, "e") == "0" + assert f.format(d, "e", locale="en-gb") == "6" + assert f.format(d.add(days=2), "e") == "2" + assert f.format(d.add(days=2), "e", locale="en-gb") == "1" + + assert f.format(d, "eo") == "1st" + assert f.format(d, "eo", locale="en-gb") == "7th" + assert f.format(d.add(days=2), "eo") == "3rd" + assert f.format(d.add(days=2), "eo", locale="en-gb") == "2nd" + + def test_day_of_iso_week(): f = Formatter() d = pendulum.datetime(2016, 8, 28) diff --git a/tests/localization/test_tr.py b/tests/localization/test_tr.py index 258a5de9..5ec00eef 100644 --- a/tests/localization/test_tr.py +++ b/tests/localization/test_tr.py @@ -49,10 +49,10 @@ def diff_for_humans(): assert d.diff_for_humans(locale=locale) == "2 ay önce" d = pendulum.now().subtract(years=1) - assert d.diff_for_humans(locale=locale) == "1 yıl önce" # noqa: RUF001 + assert d.diff_for_humans(locale=locale) == "1 yıl önce" d = pendulum.now().subtract(years=2) - assert d.diff_for_humans(locale=locale) == "2 yıl önce" # noqa: RUF001 + assert d.diff_for_humans(locale=locale) == "2 yıl önce" d = pendulum.now().add(seconds=1) assert d.diff_for_humans(locale=locale) == "1 saniye sonra" diff --git a/tests/test_helpers.py b/tests/test_helpers.py index b9ab63f8..e9317b97 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -170,10 +170,10 @@ def test_week_starts_at() -> None: def test_week_starts_at_invalid_value() -> None: with pytest.raises(ValueError): - pendulum.week_starts_at(-1) + pendulum.week_starts_at(-1) # type: ignore[arg-type] with pytest.raises(ValueError): - pendulum.week_starts_at(11) + pendulum.week_starts_at(11) # type: ignore[arg-type] def test_week_ends_at() -> None: @@ -186,7 +186,7 @@ def test_week_ends_at() -> None: def test_week_ends_at_invalid_value() -> None: with pytest.raises(ValueError): - pendulum.week_ends_at(-1) + pendulum.week_ends_at(-1) # type: ignore[arg-type] with pytest.raises(ValueError): - pendulum.week_ends_at(11) + pendulum.week_ends_at(11) # type: ignore[arg-type]