Is there a Python module to parse a date like the 'date' command in Linux?

Mike Dewhirst miked at dewhirst.com.au
Mon May 22 20:22:49 EDT 2023


On 21/05/2023 5:53 am, Chris Green wrote:
> I'm converting a bash script to python as it has become rather clumsy
> in bash.

What is the use case?

> However I have hit a problem with converting dates, the bash script
> has:-
>
>      dat=$(date --date "$1" +"%Y/%m/%d")
>
> and this will accept almost anything reasonably sensible that can be
> interpreted as a date, in particular it accepts things like "tomorrow",
> "yesterday" and "next thursday".
>
> Is there anything similar in Python or would I be better off simply
> using os.system() to run date from the python program?
>


-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://mail.python.org/pipermail/python-list/attachments/20230523/4cbf20a3/attachment.sig>


More information about the Python-list mailing list