Repository: crsmithdev/arrow
Pull request #449 (2017-08-09 15:29:23)

Add Indonesian Locale to Arrow
This PR will add Indonesian Locale to Arrow. Tests are included with the PR.


Patch:
diff --git a/arrow/locales.py b/arrow/locales.py
index bd1326d..5da7312 100644
--- a/arrow/locales.py
+++ b/arrow/locales.py
@@ -2001,5 +2001,44 @@ class SlovenianLocale(Locale):
         '', 'Pon', 'Tor', 'Sre', 'Čet', 'Pet', 'Sob', 'Ned'
     ]
 
+class IndonesianLocale(Locale):
+
+    names = ['id', 'id_id']
+
+    past = '{0} yang lalu'
+    future = 'dalam {0}'
+
+    timeframes = {
+        'now': 'baru saja',
+        'seconds': 'detik',
+        'minute': '1 menit',
+        'minutes': '{0} menit',
+        'hour': '1 jam',
+        'hours': '{0} jam',
+        'day': '1 hari',
+        'days': '{0} hari',
+        'month': '1 bulan',
+        'months': '{0} bulan',
+        'year': '1 tahun',
+        'years': '{0} tahun'
+    }
+
+    meridians = {
+        'am': '',
+        'pm': '',
+        'AM': '',
+        'PM': ''
+    }
+
+    month_names = ['', 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli',
+        'Agustus', 'September', 'Oktober', 'November', 'Desember']
+
+    month_abbreviations = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul',
+        'Ags', 'Sept', 'Okt', 'Nov', 'Des']
+
+    day_names = ['', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']
+
+    day_abbreviations = ['', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']
+
 
 _locales = _map_locales()


Test patch:
diff --git a/tests/locales_tests.py b/tests/locales_tests.py
index 1d06fb9..4f39419 100644
--- a/tests/locales_tests.py
+++ b/tests/locales_tests.py
@@ -553,3 +553,32 @@ class RomanianLocaleTests(Chai):
         self.assertEqual(self.locale._format_relative("câteva secunde", "seconds", 1), "peste câteva secunde")
         self.assertEqual(self.locale._format_relative("o zi", "day", -1), "o zi în urmă")
         self.assertEqual(self.locale._format_relative("o zi", "day", 1), "peste o zi")
+
+class IndonesianLocaleTests(Chai):
+
+    def setUp(self):
+        super(IndonesianLocaleTests, self).setUp()
+
+        self.locale = locales.IndonesianLocale()
+
+    def test_timeframes(self):
+        self.assertEqual(self.locale._format_timeframe('hours', 2), '2 jam')
+        self.assertEqual(self.locale._format_timeframe('months', 2), '2 bulan')
+
+        self.assertEqual(self.locale._format_timeframe('days', 2), '2 hari')
+        self.assertEqual(self.locale._format_timeframe('years', 2), '2 tahun')
+
+        self.assertEqual(self.locale._format_timeframe('hours', 3), '3 jam')
+        self.assertEqual(self.locale._format_timeframe('months', 4), '4 bulan')
+        self.assertEqual(self.locale._format_timeframe('days', 3), '3 hari')
+        self.assertEqual(self.locale._format_timeframe('years', 5), '5 tahun')
+
+    def test_format_relative_now(self):
+        self.assertEqual(self.locale._format_relative('baru saja', 'now', 0), 'baru saja')
+
+    def test_format_relative_past(self):
+        self.assertEqual(self.locale._format_relative('1 jam', 'hour', 1), 'dalam 1 jam')
+        self.assertEqual(self.locale._format_relative('1 detik', 'seconds', 1), 'dalam 1 detik')
+
+    def test_format_relative_future(self):
+        self.assertEqual(self.locale._format_relative('1 jam', 'hour', -1), '1 jam yang lalu')