How to use the arrow.locales function in arrow

To help you get started, we’ve selected a few arrow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crsmithdev / arrow / tests / locales_tests.py View on Github external
def setUp(self):
        super(SlovakLocaleTests, self).setUp()

        self.locale = locales.SlovakLocale()
github crsmithdev / arrow / tests / locales_tests.py View on Github external
def setUp(self):
        super(BengaliLocaleTests, self).setUp()

        self.locale = locales.BengaliLocale()
github crsmithdev / arrow / tests / locales_tests.py View on Github external
def test_couple_of_timeframe(self):
        locale = locales.HebrewLocale()

        self.assertEqual(locale._format_timeframe("hours", 2), "שעתיים")
        self.assertEqual(locale._format_timeframe("months", 2), "חודשיים")
        self.assertEqual(locale._format_timeframe("days", 2), "יומיים")
        self.assertEqual(locale._format_timeframe("years", 2), "שנתיים")

        self.assertEqual(locale._format_timeframe("hours", 3), "3 שעות")
        self.assertEqual(locale._format_timeframe("months", 4), "4 חודשים")
        self.assertEqual(locale._format_timeframe("days", 3), "3 ימים")
        self.assertEqual(locale._format_timeframe("years", 5), "5 שנים")
github crsmithdev / arrow / tests / locales_tests.py View on Github external
def setUp(self):
        super(CzechLocaleTests, self).setUp()

        self.locale = locales.CzechLocale()
github crsmithdev / arrow / tests / locales_tests.py View on Github external
def setUp(self):
        super(EsperantoLocaleTests, self).setUp()

        self.locale = locales.EsperantoLocale()
github Tautulli / Tautulli / lib / arrow / arrow.py View on Github external
:param locale: (optional) a ``str`` specifying a locale.  Defaults to 'en_us'.
        :param only_distance: (optional) returns only time difference eg: "11 seconds" without "in" or "ago" part.

        Usage::

            >>> earlier = arrow.utcnow().replace(hours=-2)
            >>> earlier.humanize()
            '2 hours ago'

            >>> later = later = earlier.replace(hours=4)
            >>> later.humanize(earlier)
            'in 4 hours'

        '''

        locale = locales.get_locale(locale)

        if other is None:
            utc = datetime.utcnow().replace(tzinfo=dateutil_tz.tzutc())
            dt = utc.astimezone(self._datetime.tzinfo)

        elif isinstance(other, Arrow):
            dt = other._datetime

        elif isinstance(other, datetime):
            if other.tzinfo is None:
                dt = other.replace(tzinfo=self._datetime.tzinfo)
            else:
                dt = other.astimezone(self._datetime.tzinfo)

        else:
            raise TypeError()
github manuelcortez / TWBlue / src / fixes / fix_arrow.py View on Github external
def fix():
	# insert a modified function so if there is no language available in arrow, returns English locale.
	locales.get_locale = get_locale
github wcaleb / ricescheduler / ricescheduler.py View on Github external
def locale():
    return arrow.locales.get_locale('en_us')