I'm converting a bash script to python as it has become rather clumsy
in bash.
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?
On 5/20/23 13:53, Chris Green wrote:
I'm converting a bash script to python as it has become rather clumsy
in bash.
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?
in the standard library, datetime
as an addon module, dateutil (install as python-dateutil)
Don't know if either are exactly what you want, but do take a look.
--
https://mail.python.org/mailman/listinfo/python-list
[-- multipart/mixed, encoding 7bit, 22 lines --]
[-- text/plain, encoding base64, charset: UTF-8, 16 lines --]
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?
Mike Dewhirst <miked@dewhirst.com.au> wrote:
[-- multipart/mixed, encoding 7bit, 22 lines --]
[-- text/plain, encoding base64, charset: UTF-8, 16 lines --]
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?
A script I use to create diary entries, so it's very handy to be able
to give the date as 'yesterday' or 'friday'.
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 446 |
Nodes: | 16 (2 / 14) |
Uptime: | 19:37:08 |
Calls: | 9,234 |
Calls today: | 1 |
Files: | 13,496 |
Messages: | 6,063,226 |