Skip to main content

DateJS Build Status

Convert Date from a JavaScript Date object to a Python DateTime object

Usage

To use this library, you must first install the library (pip install DateJS)

In your code, you must import DateJS package by including from DateJS import DateJS.

To convert JavaScript Date, initialize a DateJS object by doing DateJS(JAVASCRIPT_DATE_STRING, convert), where the JAVASCRIPT_DATE_STRING can be determined by running new Date().toString() in JavaScript and convert is whether you would like to convert the time to the server timezone.

Get Values

You can access a wide array of values by calling one of the following methods:

Year -> getYear()

Month -> getMonth()

Date -> getDate()

Hours -> getHours()

Minutes -> getMinutes()

Seconds -> getSeconds()

Milliseconds -> getMilliseconds()

Common Timezone (From pytz.common_timezones) -> getTimezone()

Time (as a DateTime object) -> getTime()

Common Errors

If you get a JavaScript Runtime Error, you can fix this by running sudo apt-get install nodejs. This will configure the JavaScript Runtime Environment.

Examples

Format: DateJS(JAVASCRIPT_STRING, convert).

from DateJS import DateJS

dJS = DateJS("Thu Oct 19 2017 21:50:06 GMT-0400 (Eastern Daylight Time)", True)

dJS.getTime() # Get datetime object of time with timezone data

dJS.getTimezone() # Returns a timezone object from pytz

If you use the example above, JavaScript will automatically convert the Date into the timezone of the python server. In order to maintain the existing timezone, you can set the convert field to False.

dJS = DateJS("Thu Oct 19 2017 21:50:06 GMT-0400 (Eastern Daylight Time)", False)

dJS.getTime() # Get datetime object of time with timezone data

dJS.getTimezone() # Returns a timezone object from pytz

Unnoticed Errors

If you would like to report any errors, please open an issue. If you know how to fix the issue, please submit appropriate changes.

Metadata

Release files for DateJS 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DateJS 0.5
File Size Uploaded Provenance Actions
DateJS-0.5.tar.gz 4.4 kB Without provenance Details for DateJS-0.5.tar.gz

Release files / DateJS-0.5.tar.gz

Download URL DateJS-0.5.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1f4961635df8bc3d3f909875a0fc4f3fe4b6ca7d5873ea0a0c9f4aba90c6d6f5
BLAKE2b-256 checksum
How to use checksums
17356e17aaf9f286ad6f8e45091ae204042345bf9cc1be4788cbffb6a5baca15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Security for DateJS 0.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page