Arrow datetime support for MongoEngine
Project description
mongoengine-arrow
Description
Arrow datetime support for MongoEngine
Install
pip3 install --upgrade mongoengine-arrow
How it works
Feed it datetime with or without timezone info in any format Arrow supports.
To confirm whether it will work, feed it to arrow.get()
function.
Usage example
# Import the field
from mongoengine_arrow import ArrowDateTimeField
...
# Define model
class MyModel(Document):
timestamp = ArrowDateTimeField(required=True)
...
# Get instance
myinstance = MyModel.objects.first()
# Get timestamp in local time
timestamp = myinstance.timestamp.to("local")
# Set timestamp in any timezone
myinstance.timestamp = arrow.get(2021, 1, 1, tzinfo="UTC")
# Set timestamp from datetime
from datetime import datetime
myinstance.timestamp = datetime(2021, 1, 1)
# Set timestamp from datetime that has tzinfo
from datetime import datetime
from dateutil.tz import gettz
myinstance.timestamp = datetime(2021, 1, 1, tzinfo=gettz("UTC+5"))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for mongoengine_arrow-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a98997b3e2d628f45f13974da4d9cee63e5284c1d14042c851c1d6d264aa33fc |
|
MD5 | 6ed59b1c5ecbbb6016d956af6b62b617 |
|
BLAKE2b-256 | af1b8316427e247627aa85a3b9ac35f5ac52822b0795999e1f3387bab428f02e |