Skip to main content

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

mongoengine-arrow-0.1.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

mongoengine_arrow-0.1.3-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file mongoengine-arrow-0.1.3.tar.gz.

File metadata

  • Download URL: mongoengine-arrow-0.1.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.2 Linux/5.10.11-zen2-1-zen

File hashes

Hashes for mongoengine-arrow-0.1.3.tar.gz
Algorithm Hash digest
SHA256 afa1a9730f1333e9e759c721a5012e5a8abe7187704fbed635776586daaf885e
MD5 4b2155021d6d676e202602dfb3c7b65e
BLAKE2b-256 e6322db1c7c7f005acc900663f477cc634ccbcf4663015a2b2dc37d6da2da02d

See more details on using hashes here.

File details

Details for the file mongoengine_arrow-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mongoengine_arrow-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.2 Linux/5.10.11-zen2-1-zen

File hashes

Hashes for mongoengine_arrow-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7ea65892ba2d8010f56d9c10557a1342b8a0f8028a2c3f7d1e8c10090ea803f8
MD5 e1220917c64c363d0bb0dd198a6bf090
BLAKE2b-256 c97fab4cb152957a52ce08e1849c5b6efa29cc26cb52e01ad6430ba4ebd5472b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page