[Chennaipy] Chennaipy - Monday Module - 22 May 2023
selvi dct
selvi.dct at gmail.com
Mon May 22 14:53:12 EDT 2023
Date: 22 May 2023
Module : arrow
Installation : pip install arrow
About:
Arrow is a Python library that offers a human-friendly approach to
creating, manipulating, formatting and converting dates, times and
timestamps. It implements and updates the datetime type, plugging gaps in
functionality and providing an intelligent module API that supports many
common creation scenarios.
Sample:
>>> import arrow
>>> arrow.get('2023-05-11T21:23:58.970460+07:00')
<Arrow [2023-05-11T21:23:58.970460+07:00]>
>>> utc = arrow.utcnow()
>>> utc
<Arrow [2023-05-11T21:23:58.970460+00:00]>
>>> utc = utc.shift(hours=-1)
>>> utc
<Arrow [2023-05-11T20:23:58.970460+00:00]>
>>> local = utc.to('US/Pacific')
>>> local
<Arrow [2023-05-11T13:23:58.970460-07:00]>
>>> local.timestamp()
1368303838.970460
>>> local.format()
'2023-05-11 13:23:58 -07:00'
>>> local.format('YYYY-MM-DD HH:mm:ss ZZ')
'2023-05-11 13:23:58 -07:00'
>>> local.humanize()
'an hour ago'
>>> local.humanize(locale='ko-kr')
'한시간 전'
Reference:
https://pypi.org/project/arrow/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/chennaipy/attachments/20230523/11f73dd6/attachment.html>
More information about the Chennaipy
mailing list