From 58aab24c286858158d66ef15bc303162179bc6a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 12 Nov 2022 17:18:11 -0800 Subject: [PATCH] Bump arrow from 1.2.2 to 1.2.3 (#1829) * Bump arrow from 1.2.2 to 1.2.3 Bumps [arrow](https://github.com/arrow-py/arrow) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/arrow-py/arrow/releases) - [Changelog](https://github.com/arrow-py/arrow/blob/master/CHANGELOG.rst) - [Commits](https://github.com/arrow-py/arrow/compare/1.2.2...1.2.3) --- updated-dependencies: - dependency-name: arrow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update arrow==1.2.3 Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci] --- lib/arrow/_version.py | 2 +- lib/arrow/arrow.py | 6 +- lib/arrow/constants.py | 12 +- lib/arrow/locales.py | 585 ++++++++++++++++++++++++++++++++++++----- requirements.txt | 2 +- 5 files changed, 540 insertions(+), 67 deletions(-) diff --git a/lib/arrow/_version.py b/lib/arrow/_version.py index bc86c944..10aa336c 100644 --- a/lib/arrow/_version.py +++ b/lib/arrow/_version.py @@ -1 +1 @@ -__version__ = "1.2.2" +__version__ = "1.2.3" diff --git a/lib/arrow/arrow.py b/lib/arrow/arrow.py index 21b0347f..1ede107f 100644 --- a/lib/arrow/arrow.py +++ b/lib/arrow/arrow.py @@ -1384,7 +1384,7 @@ class Arrow: search_string = search_string.format(r"\d+") # Create search pattern and find within string - pattern = re.compile(fr"(^|\b|\d){search_string}") + pattern = re.compile(rf"(^|\b|\d){search_string}") match = pattern.search(input_string) # If there is no match continue to next iteration @@ -1426,12 +1426,12 @@ class Arrow: # Sign logic future_string = locale_obj.future future_string = future_string.format(".*") - future_pattern = re.compile(fr"^{future_string}$") + future_pattern = re.compile(rf"^{future_string}$") future_pattern_match = future_pattern.findall(input_string) past_string = locale_obj.past past_string = past_string.format(".*") - past_pattern = re.compile(fr"^{past_string}$") + past_pattern = re.compile(rf"^{past_string}$") past_pattern_match = past_pattern.findall(input_string) # If a string contains the now unit, there will be no relative units, hence the need to check if the now unit diff --git a/lib/arrow/constants.py b/lib/arrow/constants.py index 1189d07c..53d163b9 100644 --- a/lib/arrow/constants.py +++ b/lib/arrow/constants.py @@ -21,7 +21,7 @@ except (OverflowError, ValueError, OSError): # pragma: no cover # Must get max value of ctime on Windows based on architecture (x32 vs x64) # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64 # Note: this may occur on both 32-bit Linux systems (issue #930) along with Windows systems - is_64bits = sys.maxsize > 2 ** 32 + is_64bits = sys.maxsize > 2**32 _MAX_TIMESTAMP = ( datetime(3000, 1, 1, 23, 59, 59, 999999).timestamp() if is_64bits @@ -162,6 +162,16 @@ DEHUMANIZE_LOCALES = { "ta-lk", "ur", "ur-pk", + "ka", + "ka-ge", "kk", "kk-kz", + # "lo", + # "lo-la", + "am", + "am-et", + "hy-am", + "hy", + "uz", + "uz-uz", } diff --git a/lib/arrow/locales.py b/lib/arrow/locales.py index b7fb0d32..3627497f 100644 --- a/lib/arrow/locales.py +++ b/lib/arrow/locales.py @@ -45,7 +45,6 @@ _TimeFrameElements = Union[ str, Sequence[str], Mapping[str, str], Mapping[str, Sequence[str]] ] - _locale_map: Dict[str, Type["Locale"]] = {} @@ -296,7 +295,6 @@ class Locale: class EnglishLocale(Locale): - names = [ "en", "en-us", @@ -560,7 +558,6 @@ class SpanishLocale(Locale): class FrenchBaseLocale(Locale): - past = "il y a {0}" future = "dans {0}" and_word = "et" @@ -622,7 +619,6 @@ class FrenchBaseLocale(Locale): class FrenchLocale(FrenchBaseLocale, Locale): - names = ["fr", "fr-fr"] month_abbreviations = [ @@ -643,7 +639,6 @@ class FrenchLocale(FrenchBaseLocale, Locale): class FrenchCanadianLocale(FrenchBaseLocale, Locale): - names = ["fr-ca"] month_abbreviations = [ @@ -664,7 +659,6 @@ class FrenchCanadianLocale(FrenchBaseLocale, Locale): class GreekLocale(Locale): - names = ["el", "el-gr"] past = "{0} πριν" @@ -734,7 +728,6 @@ class GreekLocale(Locale): class JapaneseLocale(Locale): - names = ["ja", "ja-jp"] past = "{0}前" @@ -795,7 +788,6 @@ class JapaneseLocale(Locale): class SwedishLocale(Locale): - names = ["sv", "sv-se"] past = "för {0} sen" @@ -865,7 +857,6 @@ class SwedishLocale(Locale): class FinnishLocale(Locale): - names = ["fi", "fi-fi"] # The finnish grammar is very complex, and its hard to convert @@ -952,7 +943,6 @@ class FinnishLocale(Locale): class ChineseCNLocale(Locale): - names = ["zh", "zh-cn"] past = "{0}前" @@ -1012,7 +1002,6 @@ class ChineseCNLocale(Locale): class ChineseTWLocale(Locale): - names = ["zh-tw"] past = "{0}前" @@ -1073,7 +1062,6 @@ class ChineseTWLocale(Locale): class HongKongLocale(Locale): - names = ["zh-hk"] past = "{0}前" @@ -1133,7 +1121,6 @@ class HongKongLocale(Locale): class KoreanLocale(Locale): - names = ["ko", "ko-kr"] past = "{0} 전" @@ -1229,7 +1216,6 @@ class KoreanLocale(Locale): # derived locale types & implementations. class DutchLocale(Locale): - names = ["nl", "nl-nl"] past = "{0} geleden" @@ -1318,7 +1304,6 @@ class SlavicBaseLocale(Locale): class BelarusianLocale(SlavicBaseLocale): - names = ["be", "be-by"] past = "{0} таму" @@ -1397,7 +1382,6 @@ class BelarusianLocale(SlavicBaseLocale): class PolishLocale(SlavicBaseLocale): - names = ["pl", "pl-pl"] past = "{0} temu" @@ -1488,7 +1472,6 @@ class PolishLocale(SlavicBaseLocale): class RussianLocale(SlavicBaseLocale): - names = ["ru", "ru-ru"] past = "{0} назад" @@ -1579,7 +1562,6 @@ class RussianLocale(SlavicBaseLocale): class AfrikaansLocale(Locale): - names = ["af", "af-nl"] past = "{0} gelede" @@ -1646,7 +1628,6 @@ class AfrikaansLocale(Locale): class BulgarianLocale(SlavicBaseLocale): - names = ["bg", "bg-bg"] past = "{0} назад" @@ -1725,7 +1706,6 @@ class BulgarianLocale(SlavicBaseLocale): class UkrainianLocale(SlavicBaseLocale): - names = ["ua", "uk", "uk-ua"] past = "{0} тому" @@ -1903,7 +1883,6 @@ class MacedonianLocale(SlavicBaseLocale): class GermanBaseLocale(Locale): - past = "vor {0}" future = "in {0}" and_word = "und" @@ -2009,17 +1988,14 @@ class GermanBaseLocale(Locale): class GermanLocale(GermanBaseLocale, Locale): - names = ["de", "de-de"] class SwissLocale(GermanBaseLocale, Locale): - names = ["de-ch"] class AustrianLocale(GermanBaseLocale, Locale): - names = ["de-at"] month_names = [ @@ -2040,7 +2016,6 @@ class AustrianLocale(GermanBaseLocale, Locale): class NorwegianLocale(Locale): - names = ["nb", "nb-no"] past = "for {0} siden" @@ -2112,7 +2087,6 @@ class NorwegianLocale(Locale): class NewNorwegianLocale(Locale): - names = ["nn", "nn-no"] past = "for {0} sidan" @@ -2259,7 +2233,6 @@ class BrazilianPortugueseLocale(PortugueseLocale): class TagalogLocale(Locale): - names = ["tl", "tl-ph"] past = "nakaraang {0}" @@ -2333,7 +2306,6 @@ class TagalogLocale(Locale): class VietnameseLocale(Locale): - names = ["vi", "vi-vn"] past = "{0} trước" @@ -2402,7 +2374,6 @@ class VietnameseLocale(Locale): class TurkishLocale(Locale): - names = ["tr", "tr-tr"] past = "{0} önce" @@ -2474,7 +2445,6 @@ class TurkishLocale(Locale): class AzerbaijaniLocale(Locale): - names = ["az", "az-az"] past = "{0} əvvəl" @@ -2862,23 +2832,24 @@ class IcelandicLocale(Locale): class DanishLocale(Locale): - names = ["da", "da-dk"] past = "for {0} siden" - future = "efter {0}" + future = "om {0}" and_word = "og" timeframes = { "now": "lige nu", "second": "et sekund", - "seconds": "{0} et par sekunder", + "seconds": "{0} sekunder", "minute": "et minut", "minutes": "{0} minutter", "hour": "en time", "hours": "{0} timer", "day": "en dag", "days": "{0} dage", + "week": "en uge", + "weeks": "{0} uger", "month": "en måned", "months": "{0} måneder", "year": "et år", @@ -2928,9 +2899,11 @@ class DanishLocale(Locale): ] day_abbreviations = ["", "man", "tir", "ons", "tor", "fre", "lør", "søn"] + def _ordinal_number(self, n: int) -> str: + return f"{n}." + class MalayalamLocale(Locale): - names = ["ml"] past = "{0} മുമ്പ്" @@ -3004,7 +2977,6 @@ class MalayalamLocale(Locale): class HindiLocale(Locale): - names = ["hi", "hi-in"] past = "{0} पहले" @@ -3333,7 +3305,6 @@ class SlovakLocale(Locale): class FarsiLocale(Locale): - names = ["fa", "fa-ir"] past = "{0} قبل" @@ -3407,7 +3378,6 @@ class FarsiLocale(Locale): class HebrewLocale(Locale): - names = ["he", "he-il"] past = "לפני {0}" @@ -3518,7 +3488,6 @@ class HebrewLocale(Locale): class MarathiLocale(Locale): - names = ["mr"] past = "{0} आधी" @@ -3725,7 +3694,6 @@ class BasqueLocale(Locale): class HungarianLocale(Locale): - names = ["hu", "hu-hu"] past = "{0} ezelőtt" @@ -3877,7 +3845,6 @@ class EsperantoLocale(Locale): class ThaiLocale(Locale): - names = ["th", "th-th"] past = "{0} ที่ผ่านมา" @@ -3966,8 +3933,115 @@ class ThaiLocale(Locale): return relative_string -class BengaliLocale(Locale): +class LaotianLocale(Locale): + names = ["lo", "lo-la"] + + past = "{0} ກ່ອນຫນ້ານີ້" + future = "ໃນ {0}" + + timeframes = { + "now": "ດຽວນີ້", + "second": "ວິນາທີ", + "seconds": "{0} ວິນາທີ", + "minute": "ນາທີ", + "minutes": "{0} ນາທີ", + "hour": "ຊົ່ວໂມງ", + "hours": "{0} ຊົ່ວໂມງ", + "day": "ມື້", + "days": "{0} ມື້", + "week": "ອາທິດ", + "weeks": "{0} ອາທິດ", + "month": "ເດືອນ", + "months": "{0} ເດືອນ", + "year": "ປີ", + "years": "{0} ປີ", + } + + month_names = [ + "", + "ມັງກອນ", # mangkon + "ກຸມພາ", # kumpha + "ມີນາ", # mina + "ເມສາ", # mesa + "ພຶດສະພາ", # phudsapha + "ມິຖຸນາ", # mithuna + "ກໍລະກົດ", # kolakod + "ສິງຫາ", # singha + "ກັນຍາ", # knaia + "ຕຸລາ", # tula + "ພະຈິກ", # phachik + "ທັນວາ", # thanuaa + ] + month_abbreviations = [ + "", + "ມັງກອນ", + "ກຸມພາ", + "ມີນາ", + "ເມສາ", + "ພຶດສະພາ", + "ມິຖຸນາ", + "ກໍລະກົດ", + "ສິງຫາ", + "ກັນຍາ", + "ຕຸລາ", + "ພະຈິກ", + "ທັນວາ", + ] + + day_names = [ + "", + "ວັນຈັນ", # vanchan + "ວັນອັງຄານ", # vnoangkhan + "ວັນພຸດ", # vanphud + "ວັນພະຫັດ", # vanphahad + "ວັນ​ສຸກ", # vansuk + "ວັນເສົາ", # vansao + "ວັນອາທິດ", # vnoathid + ] + day_abbreviations = [ + "", + "ວັນຈັນ", + "ວັນອັງຄານ", + "ວັນພຸດ", + "ວັນພະຫັດ", + "ວັນ​ສຸກ", + "ວັນເສົາ", + "ວັນອາທິດ", + ] + + BE_OFFSET = 543 + + def year_full(self, year: int) -> str: + """Lao always use Buddhist Era (BE) which is CE + 543""" + year += self.BE_OFFSET + return f"{year:04d}" + + def year_abbreviation(self, year: int) -> str: + """Lao always use Buddhist Era (BE) which is CE + 543""" + year += self.BE_OFFSET + return f"{year:04d}"[2:] + + def _format_relative( + self, + humanized: str, + timeframe: TimeFrameLiteral, + delta: Union[float, int], + ) -> str: + """Lao normally doesn't have any space between words""" + if timeframe == "now": + return humanized + + direction = self.past if delta < 0 else self.future + relative_string = direction.format(humanized) + + if timeframe == "seconds": + relative_string = relative_string.replace(" ", "") + + return relative_string + + +class BengaliLocale(Locale): names = ["bn", "bn-bd", "bn-in"] past = "{0} আগে" @@ -4048,7 +4122,6 @@ class BengaliLocale(Locale): class RomanshLocale(Locale): - names = ["rm", "rm-ch"] past = "avant {0}" @@ -4255,7 +4328,6 @@ class SlovenianLocale(Locale): class IndonesianLocale(Locale): - names = ["id", "id-id"] past = "{0} yang lalu" @@ -4475,7 +4547,6 @@ class EstonianLocale(Locale): class LatvianLocale(Locale): - names = ["lv", "lv-lv"] past = "pirms {0}" @@ -4556,7 +4627,6 @@ class LatvianLocale(Locale): class SwahiliLocale(Locale): - names = [ "sw", "sw-ke", @@ -4641,7 +4711,6 @@ class SwahiliLocale(Locale): class CroatianLocale(Locale): - names = ["hr", "hr-hr"] past = "prije {0}" @@ -4733,7 +4802,6 @@ class CroatianLocale(Locale): class LatinLocale(Locale): - names = ["la", "la-va"] past = "ante {0}" @@ -4814,7 +4882,6 @@ class LatinLocale(Locale): class LithuanianLocale(Locale): - names = ["lt", "lt-lt"] past = "prieš {0}" @@ -4895,7 +4962,6 @@ class LithuanianLocale(Locale): class MalayLocale(Locale): - names = ["ms", "ms-my", "ms-bn"] past = "{0} yang lalu" @@ -4976,7 +5042,6 @@ class MalayLocale(Locale): class MalteseLocale(Locale): - names = ["mt", "mt-mt"] past = "{0} ilu" @@ -5068,7 +5133,6 @@ class MalteseLocale(Locale): class SamiLocale(Locale): - names = ["se", "se-fi", "se-no", "se-se"] past = "{0} dassái" @@ -5148,7 +5212,6 @@ class SamiLocale(Locale): class OdiaLocale(Locale): - names = ["or", "or-in"] past = "{0} ପୂର୍ବେ" @@ -5239,7 +5302,6 @@ class OdiaLocale(Locale): class SerbianLocale(Locale): - names = ["sr", "sr-rs", "sr-sp"] past = "pre {0}" @@ -5331,7 +5393,6 @@ class SerbianLocale(Locale): class LuxembourgishLocale(Locale): - names = ["lb", "lb-lu"] past = "virun {0}" @@ -5422,7 +5483,6 @@ class LuxembourgishLocale(Locale): delta: Union[int, float] = 0, only_distance: bool = False, ) -> str: - if not only_distance: return super().describe(timeframe, delta, only_distance) @@ -5433,7 +5493,6 @@ class LuxembourgishLocale(Locale): class ZuluLocale(Locale): - names = ["zu", "zu-za"] past = "{0} edlule" @@ -5531,7 +5590,6 @@ class ZuluLocale(Locale): class TamilLocale(Locale): - names = ["ta", "ta-in", "ta-lk"] past = "{0} நேரத்திற்கு முன்பு" @@ -5619,7 +5677,6 @@ class TamilLocale(Locale): class AlbanianLocale(Locale): - names = ["sq", "sq-al"] past = "{0} më parë" @@ -5699,8 +5756,91 @@ class AlbanianLocale(Locale): ] -class SinhalaLocale(Locale): +class GeorgianLocale(Locale): + names = ["ka", "ka-ge"] + past = "{0} წინ" # ts’in + future = "{0} შემდეგ" # shemdeg + and_word = "და" # da + + timeframes = { + "now": "ახლა", # akhla + # When a cardinal qualifies a noun, it stands in the singular + "second": "წამის", # ts’amis + "seconds": "{0} წამის", + "minute": "წუთის", # ts’utis + "minutes": "{0} წუთის", + "hour": "საათის", # saatis + "hours": "{0} საათის", + "day": "დღის", # dghis + "days": "{0} დღის", + "week": "კვირის", # k’viris + "weeks": "{0} კვირის", + "month": "თვის", # tvis + "months": "{0} თვის", + "year": "წლის", # ts’lis + "years": "{0} წლის", + } + + month_names = [ + # modern month names + "", + "იანვარი", # Ianvari + "თებერვალი", # Tebervali + "მარტი", # Mart'i + "აპრილი", # Ap'rili + "მაისი", # Maisi + "ივნისი", # Ivnisi + "ივლისი", # Ivlisi + "აგვისტო", # Agvist'o + "სექტემბერი", # Sekt'emberi + "ოქტომბერი", # Okt'omberi + "ნოემბერი", # Noemberi + "დეკემბერი", # Dek'emberi + ] + + month_abbreviations = [ + # no abbr. found yet + "", + "იანვარი", # Ianvari + "თებერვალი", # Tebervali + "მარტი", # Mart'i + "აპრილი", # Ap'rili + "მაისი", # Maisi + "ივნისი", # Ivnisi + "ივლისი", # Ivlisi + "აგვისტო", # Agvist'o + "სექტემბერი", # Sekt'emberi + "ოქტომბერი", # Okt'omberi + "ნოემბერი", # Noemberi + "დეკემბერი", # Dek'emberi + ] + + day_names = [ + "", + "ორშაბათი", # orshabati + "სამშაბათი", # samshabati + "ოთხშაბათი", # otkhshabati + "ხუთშაბათი", # khutshabati + "პარასკევი", # p’arask’evi + "შაბათი", # shabati + # "k’vira" also serves as week; to avoid confusion "k’vira-dge" can be used for Sunday + "კვირა", # k’vira + ] + + day_abbreviations = [ + "", + "ორშაბათი", # orshabati + "სამშაბათი", # samshabati + "ოთხშაბათი", # otkhshabati + "ხუთშაბათი", # khutshabati + "პარასკევი", # p’arask’evi + "შაბათი", # shabati + "კვირა", # k’vira + ] + + +class SinhalaLocale(Locale): names = ["si", "si-lk"] past = "{0}ට පෙර" @@ -5864,7 +6004,6 @@ class SinhalaLocale(Locale): class UrduLocale(Locale): - names = ["ur", "ur-pk"] past = "پہلے {0}" @@ -5945,7 +6084,6 @@ class UrduLocale(Locale): class KazakhLocale(Locale): - names = ["kk", "kk-kz"] past = "{0} бұрын" @@ -6010,3 +6148,328 @@ class KazakhLocale(Locale): "Жексенбі", ] day_abbreviations = ["", "Дс", "Сс", "Ср", "Бс", "Жм", "Сб", "Жс"] + + +class AmharicLocale(Locale): + names = ["am", "am-et"] + + past = "{0} በፊት" + future = "{0} ውስጥ" + and_word = "እና" + + timeframes: ClassVar[Mapping[TimeFrameLiteral, Union[Mapping[str, str], str]]] = { + "now": "አሁን", + "second": { + "past": "ከአንድ ሰከንድ", + "future": "በአንድ ሰከንድ", + }, + "seconds": { + "past": "ከ {0} ሰከንድ", + "future": "በ {0} ሰከንድ", + }, + "minute": { + "past": "ከአንድ ደቂቃ", + "future": "በአንድ ደቂቃ", + }, + "minutes": { + "past": "ከ {0} ደቂቃዎች", + "future": "በ {0} ደቂቃዎች", + }, + "hour": { + "past": "ከአንድ ሰዓት", + "future": "በአንድ ሰዓት", + }, + "hours": { + "past": "ከ {0} ሰዓታት", + "future": "በ {0} ሰከንድ", + }, + "day": { + "past": "ከአንድ ቀን", + "future": "በአንድ ቀን", + }, + "days": { + "past": "ከ {0} ቀናት", + "future": "በ {0} ቀናት", + }, + "week": { + "past": "ከአንድ ሳምንት", + "future": "በአንድ ሳምንት", + }, + "weeks": { + "past": "ከ {0} ሳምንታት", + "future": "በ {0} ሳምንታት", + }, + "month": { + "past": "ከአንድ ወር", + "future": "በአንድ ወር", + }, + "months": { + "past": "ከ {0} ወር", + "future": "በ {0} ወራት", + }, + "year": { + "past": "ከአንድ አመት", + "future": "በአንድ አመት", + }, + "years": { + "past": "ከ {0} ዓመታት", + "future": "በ {0} ዓመታት", + }, + } + # Amharic: the general format to describe timeframe is different from past and future, + # so we do not copy the original timeframes dictionary + timeframes_only_distance = { + "second": "አንድ ሰከንድ", + "seconds": "{0} ሰከንድ", + "minute": "አንድ ደቂቃ", + "minutes": "{0} ደቂቃዎች", + "hour": "አንድ ሰዓት", + "hours": "{0} ሰዓት", + "day": "አንድ ቀን", + "days": "{0} ቀናት", + "week": "አንድ ሳምንት", + "weeks": "{0} ሳምንት", + "month": "አንድ ወር", + "months": "{0} ወራት", + "year": "አንድ አመት", + "years": "{0} ዓመታት", + } + + month_names = [ + "", + "ጃንዩወሪ", + "ፌብሩወሪ", + "ማርች", + "ኤፕሪል", + "ሜይ", + "ጁን", + "ጁላይ", + "ኦገስት", + "ሴፕቴምበር", + "ኦክቶበር", + "ኖቬምበር", + "ዲሴምበር", + ] + + month_abbreviations = [ + "", + "ጃንዩ", + "ፌብሩ", + "ማርች", + "ኤፕሪ", + "ሜይ", + "ጁን", + "ጁላይ", + "ኦገስ", + "ሴፕቴ", + "ኦክቶ", + "ኖቬም", + "ዲሴም", + ] + + day_names = [ + "", + "ሰኞ", + "ማክሰኞ", + "ረቡዕ", + "ሐሙስ", + "ዓርብ", + "ቅዳሜ", + "እሑድ", + ] + day_abbreviations = ["", "እ", "ሰ", "ማ", "ረ", "ሐ", "ዓ", "ቅ"] + + def _ordinal_number(self, n: int) -> str: + return f"{n}ኛ" + + def _format_timeframe(self, timeframe: TimeFrameLiteral, delta: int) -> str: + """ + Amharic awares time frame format function, takes into account + the differences between general, past, and future forms (three different suffixes). + """ + abs_delta = abs(delta) + form = self.timeframes[timeframe] + + if isinstance(form, str): + return form.format(abs_delta) + + if delta > 0: + key = "future" + else: + key = "past" + form = form[key] + + return form.format(abs_delta) + + def describe( + self, + timeframe: TimeFrameLiteral, + delta: Union[float, int] = 1, # key is always future when only_distance=False + only_distance: bool = False, + ) -> str: + """Describes a delta within a timeframe in plain language. + + :param timeframe: a string representing a timeframe. + :param delta: a quantity representing a delta in a timeframe. + :param only_distance: return only distance eg: "11 seconds" without "in" or "ago" keywords + """ + + if not only_distance: + return super().describe(timeframe, delta, only_distance) + humanized = self.timeframes_only_distance[timeframe].format(trunc(abs(delta))) + + return humanized + + +class ArmenianLocale(Locale): + names = ["hy", "hy-am"] + past = "{0} առաջ" + future = "{0}ից" + and_word = "Եվ" # Yev + + timeframes = { + "now": "հիմա", + "second": "վայրկյան", + "seconds": "{0} վայրկյան", + "minute": "րոպե", + "minutes": "{0} րոպե", + "hour": "ժամ", + "hours": "{0} ժամ", + "day": "օր", + "days": "{0} օր", + "month": "ամիս", + "months": "{0} ամիս", + "year": "տարին", + "years": "{0} տարին", + "week": "շաբաթ", + "weeks": "{0} շաբաթ", + } + + meridians = { + "am": "Ամ", + "pm": "պ.մ.", + "AM": "Ամ", + "PM": "պ.մ.", + } + + month_names = [ + "", + "հունվար", + "փետրվար", + "մարտ", + "ապրիլ", + "մայիս", + "հունիս", + "հուլիս", + "օգոստոս", + "սեպտեմբեր", + "հոկտեմբեր", + "նոյեմբեր", + "դեկտեմբեր", + ] + + month_abbreviations = [ + "", + "հունվար", + "փետրվար", + "մարտ", + "ապրիլ", + "մայիս", + "հունիս", + "հուլիս", + "օգոստոս", + "սեպտեմբեր", + "հոկտեմբեր", + "նոյեմբեր", + "դեկտեմբեր", + ] + + day_names = [ + "", + "երկուշաբթի", + "երեքշաբթի", + "չորեքշաբթի", + "հինգշաբթի", + "ուրբաթ", + "շաբաթ", + "կիրակի", + ] + + day_abbreviations = [ + "", + "երկ.", + "երեք.", + "չորեք.", + "հինգ.", + "ուրբ.", + "շաբ.", + "կիր.", + ] + + +class UzbekLocale(Locale): + names = ["uz", "uz-uz"] + past = "{0}dan avval" + future = "{0}dan keyin" + timeframes = { + "now": "hozir", + "second": "bir soniya", + "seconds": "{0} soniya", + "minute": "bir daqiqa", + "minutes": "{0} daqiqa", + "hour": "bir soat", + "hours": "{0} soat", + "day": "bir kun", + "days": "{0} kun", + "week": "bir hafta", + "weeks": "{0} hafta", + "month": "bir oy", + "months": "{0} oy", + "year": "bir yil", + "years": "{0} yil", + } + + month_names = [ + "", + "Yanvar", + "Fevral", + "Mart", + "Aprel", + "May", + "Iyun", + "Iyul", + "Avgust", + "Sentyabr", + "Oktyabr", + "Noyabr", + "Dekabr", + ] + + month_abbreviations = [ + "", + "Yan", + "Fev", + "Mar", + "Apr", + "May", + "Iyn", + "Iyl", + "Avg", + "Sen", + "Okt", + "Noy", + "Dek", + ] + + day_names = [ + "", + "Dushanba", + "Seshanba", + "Chorshanba", + "Payshanba", + "Juma", + "Shanba", + "Yakshanba", + ] + + day_abbreviations = ["", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan", "Yak"] diff --git a/requirements.txt b/requirements.txt index ea2263ac..fd8a848c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ appdirs==1.4.4 apscheduler==3.9.1 -arrow==1.2.2 +arrow==1.2.3 backports.csv==1.0.7 backports.functools-lru-cache==1.6.4 backports.zoneinfo==0.2.1