def format(self, fmt='YYYY-MM-DD HH:mm:ssZZ', locale=None): ''' Returns a string representation of the :class:`Arrow <arrow.arrow.Arrow>` object, formatted according to a format string. :param fmt: the format string. Usage:: >>> arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ') '2013-05-09 03:56:47 -00:00' >>> arrow.utcnow().format('X') '1368071882' >>> arrow.utcnow().format('MMMM DD, YYYY') 'May 09, 2013' >>> arrow.utcnow().format() '2013-05-09 03:56:47 -00:00' ''' if locale is None: if hasattr(self, 'locale') and self.locale: locale = self.locale else: locale = 'en_us' return formatter.DateTimeFormatter(locale).format(self._datetime, fmt)
def format(self, fmt="YYYY-MM-DD HH:mm:ssZZ", locale="en_us"): """ Returns a string representation of the :class:`Arrow <arrow.arrow.Arrow>` object, formatted according to a format string. :param fmt: the format string. Usage:: >>> arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ') '2013-05-09 03:56:47 -00:00' >>> arrow.utcnow().format('X') '1368071882' >>> arrow.utcnow().format('x') '1575957563663201' >>> arrow.utcnow().format('MMMM DD, YYYY') 'May 09, 2013' >>> arrow.utcnow().format() '2013-05-09 03:56:47 -00:00' """ return formatter.DateTimeFormatter(locale).format(self._datetime, fmt)
def format(self, fmt='YYYY-MM-DD HH:mm:ssZZ'): ''' Returns a string representation of the :class:`Arrow <arrow.arrow.Arrow>` object, formatted according to a format string. :param fmt: the format string. Usage:: >>> arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ') '2013-05-09 03:56:47 -00:00' >>> arrow.utcnow().format('X') '1368071882' >>> arrow.utcnow().format('MMMM DD, YYYY') 'May 09, 2013' >>> arrow.utcnow().format() '2013-05-09 03:56:47 -00:00' ''' return formatter.DateTimeFormatter().format(self._datetime, fmt)
def setUp(self): super(DateTimeFormatterFormatTokenTests, self).setUp() self.formatter = formatter.DateTimeFormatter()
def setup_class(cls): cls.formatter = formatter.DateTimeFormatter()
def arrow_formatter(request): request.cls.formatter = formatter.DateTimeFormatter()