localnow
Description
This small Python package is a drop-in replacement for datetime.datetime.now that returns the current time in the
local timezone.
Usage
Suppose you want the current date and time. You could do this:
import datetime
x = datetime.datetime.now()
By default, x will be in UTC. datetime.datetime.now takes an optional tz argument that you can use to specify a
different timezone. However, if you want to use your local timezone, wherever that may be, you need an extra step:
import datetime
tz = datetime.datetime.utcnow().astimezone().tzinfo
x = datetime.datetime.now(tz=tz)
Personally, I find the tz = ... line to be a bit of a distraction and difficult to remember, so I made this package.
It provides a drop-in replacement for datetime.datetime.now that is essentially does the same as the code above but
with a little less code:
from localnow import now
x = now()
That's it.
Installation
You can install this package from PyPI:
pip install localnow
License
MIT
Metadata
Release files for localnow 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| localnow-0.1.0.tar.gz | 2.7 kB | Without provenance | Details for localnow-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| localnow-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for localnow-0.1.0-py3-none-any.whl |
Total release size: 6.3 kB
Release files / localnow-0.1.0.tar.gz
| Download URL | localnow-0.1.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f74ffca422b8118633fe888b88c57d2ac58f8640fd5143d6116fc480de9e24e1
|
|
BLAKE2b-256 checksum How to use checksums |
26a07d11e5625ddf82d349ad018e126020139b1e2a34a5c73369ad53af848be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0
|
Release files / localnow-0.1.0-py3-none-any.whl
| Download URL | localnow-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88a063957931719e1837befa31c99061772fbca3c23c625c6d8e6f81f82d3a29
|
|
BLAKE2b-256 checksum How to use checksums |
366c5d0640e2231cf60e7bc99484649d9f9abd0cb589362861eb18590b97ef96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0
|
Security for localnow 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.