Skip to content

Commit

Permalink
Add datetime provider for bn_BD (#1518)
Browse files Browse the repository at this point in the history
* Add bn_bd package in date_time with test.

* Remove extra trailing spaces.
  • Loading branch information
jabertuhin authored Sep 24, 2021
1 parent b6bb564 commit dc2c301
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions faker/providers/date_time/bn_BD/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from .. import Provider as DateTimeProvider


class Provider(DateTimeProvider):

DAY_NAMES = {
"0": "রবিবার",
"1": "সোমবার",
"2": "মঙ্গলবার",
"3": "বুধবার",
"4": "বৃহস্পতিবার",
"5": "শুক্রবার",
"6": "শনিবার",
}

MONTH_NAMES = {
"01": "জানুয়ারি",
"02": "ফেব্রুয়ারি",
"03": "মার্চ",
"04": "এপ্রিল",
"05": "মে",
"06": "জুন",
"07": "জুলাই",
"08": "আগস্ট",
"09": "সেপ্টেম্বর",
"10": "অক্টোবর",
"11": "নভেম্বর",
"12": "ডিসেম্বর",
}

def day_of_week(self):
day = self.date("%w")
return self.DAY_NAMES[day]

def month_name(self):
month = self.month()
return self.MONTH_NAMES[month]
16 changes: 16 additions & 0 deletions tests/providers/test_date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from faker.providers.date_time import change_year
from faker.providers.date_time.ar_AA import Provider as ArProvider
from faker.providers.date_time.ar_EG import Provider as EgProvider
from faker.providers.date_time.bn_BD import Provider as BnBdProvider
from faker.providers.date_time.cs_CZ import Provider as CsCzProvider
from faker.providers.date_time.de_AT import Provider as DeAtProvider
from faker.providers.date_time.de_DE import Provider as DeDeProvider
Expand Down Expand Up @@ -1147,3 +1148,18 @@ def test_day(self):
def test_month(self):
month = self.fake.month_name()
assert month in RoRoProvider.MONTH_NAMES.values()


class TestBnBd(unittest.TestCase):

def setUp(self):
self.fake = Faker('bn_BD')
Faker.seed(0)

def test_day(self):
day = self.fake.day_of_week()
assert day in BnBdProvider.DAY_NAMES.values()

def test_month(self):
month = self.fake.month_name()
assert month in BnBdProvider.MONTH_NAMES.values()

0 comments on commit dc2c301

Please sign in to comment.