diff --git a/faker/providers/date_time/gu_IN/__init__.py b/faker/providers/date_time/gu_IN/__init__.py new file mode 100644 index 0000000000..aab4d02c62 --- /dev/null +++ b/faker/providers/date_time/gu_IN/__init__.py @@ -0,0 +1,76 @@ +from .. import Provider as DateTimeProvider + + +class Provider(DateTimeProvider): + + DAY_NAMES = { + "0": "Ravivar", + "1": "Somvar", + "2": "Mangalvar", + "3": "Budhvar", + "4": "Guruvar", + "5": "Shukravar", + "6": "Shanivar", + } + + DAY_NAMES_IN_GUJARATI = { + "0": "રવિવાર", + "1": "સોમવાર", + "2": "મંગળવાર", + "3": "બુધવાર", + "4": "ગુરુવાર", + "5": "શુક્રવાર", + "6": "શનિવાર", + } + + MONTH_NAMES = { + "01": "Kartak", + "02": "Magshar", + "03": "Posh", + "04": "Maha", + "05": "Fagan", + "06": "Chaitra", + "07": "Vaishakh", + "08": "Jeth", + "09": "Ashadh", + "10": "Shravan", + "11": "Bhadarvo", + "12": "Aaso", + } + + MONTH_NAMES_IN_GUJARATI = { + "01": "કારતક", + "02": "માગશર", + "03": "પોષ", + "04": "મહા", + "05": "ફાગણ", + "06": "ચૈત્ર", + "07": "વૈશાખ", + "08": "જેઠ", + "09": "અષાઢ", + "10": "શ્રાવણ", + "11": "ભાદરવો", + "12": "આસો", + } + + def day_of_week(self) -> str: + day = self.date("%w") + return self.DAY_NAMES[day] + + def month_name(self) -> str: + month = self.month() + return self.MONTH_NAMES[month] + + def day_of_week_in_guj(self) -> str: + """Returns day of the week in `Gujarati`""" + day = self.date("%w") + return self.DAY_NAMES_IN_GUJARATI[day] + + def month_name_in_guj(self) -> str: + """Returns month name in `Gujarati`""" + month = self.month() + return self.MONTH_NAMES_IN_GUJARATI[month] + + def month_in_guj(self) -> str: + """Returns month name in `Gujarati`""" + return self.month_name() diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py index 0ad57b03e4..3349e2aaf6 100644 --- a/tests/providers/test_date_time.py +++ b/tests/providers/test_date_time.py @@ -26,6 +26,7 @@ from faker.providers.date_time.el_GR import Provider as ElGrProvider from faker.providers.date_time.es_ES import Provider as EsEsProvider from faker.providers.date_time.fr_FR import Provider as FrFrProvider +from faker.providers.date_time.gu_IN import Provider as GuINProvider from faker.providers.date_time.hy_AM import Provider as HyAmProvider from faker.providers.date_time.it_IT import Provider as ItItProvider from faker.providers.date_time.ja_JP import Provider as JaJpProvider @@ -1357,6 +1358,35 @@ def test_month(self): assert day in FrFrProvider.MONTH_NAMES.values() +class TestGuIN(unittest.TestCase): + """Test `gu_IN` (Gujarati) provider for date_time""" + + def setUp(self): + self.fake = Faker("gu_IN") + Faker.seed(0) + + def test_day(self): + day = self.fake.day_of_week() + assert day in GuINProvider.DAY_NAMES.values() + + def test_month(self): + month = self.fake.month_name() + assert month in GuINProvider.MONTH_NAMES.values() + + def test_day_in_guj(self): + day = self.fake.day_of_week_in_guj() + assert day in GuINProvider.DAY_NAMES_IN_GUJARATI.values() + + def test_month_in_guj(self): + """Test `month_in_guj` and `month_names_in_guj` methods""" + + month = self.fake.month_name_in_guj() + assert month in GuINProvider.MONTH_NAMES_IN_GUJARATI.values() + + month = self.fake.month_in_guj() + assert month in GuINProvider.MONTH_NAMES_IN_GUJARATI.values() + + class TestJaJp(unittest.TestCase): def setUp(self): self.fake = Faker("ja_JP")