https://github.com/buscedv/pyepoch
PyEpoch is aPython module that can convert timezones, set time and calculate seconds since the UNIX epoch
https://github.com/buscedv/pyepoch
converter date datetime epoch module python time timezone timezones
Last synced: 10 months ago
JSON representation
PyEpoch is aPython module that can convert timezones, set time and calculate seconds since the UNIX epoch
- Host: GitHub
- URL: https://github.com/buscedv/pyepoch
- Owner: Buscedv
- License: gpl-3.0
- Created: 2018-11-08T09:19:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-09T19:56:34.000Z (almost 6 years ago)
- Last Synced: 2025-01-30T19:42:23.530Z (12 months ago)
- Topics: converter, date, datetime, epoch, module, python, time, timezone, timezones
- Language: Python
- Homepage: https://buscedv.github.io/PyEpoch
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyEpoch
A Python module that converts timezones, sets time and calculates the number of seconds since the UNIX epoch.
# Installation
Download the epoch.py file and then import it into your python project.
```python
import pyepoch
```
# Basic usage
How to use PyEpoch.
```python
# Gets today's date.
today = pyepoch.today()
```
# Documentation
## Today()
### The today() function
Returns today's date using _datetime.datetime_
### Ex.
```python
# Gets today's date.
today = pyepoch.today()
>>> 2018, 11, 8, 11, 32, 59, 744692
```
## Epoch_Sec()
### The epoch_sec() function
Returns the number of seconds passed up to a specific date since the Unix epoch.
The function takes two parameters:
- A date: a datetime object
- A timezone: a timezone string, ex. 'US/Pacific'
### Ex.
```python
# Gets today's date.
today = pyepoch.today()
# Seconds up to today since the Unix epoch.
today = pyepoch.epoch_sec(today, 'US/Pacific')
>>> 2018, 11, 8, 11, 32, 59, 744692-08:00
```
## Timezone_Set()
### The timezone_set() function
Returns a passed in time into another timezone (also passed in) and sets the hour/minute/second in the passed in date.
The function takes five parameters:
- A date: a datetime object to be converted.
- A timezone: a timezone string, ex. 'US/Pacific'
- Hour int
- Minute int
- Second int
### Ex.
```python
# Gets today's date.
today = pyepoch.today()
# Midnight pacific time today.
today = pyepoch.timezone(today, 'US/Pacific', 0, 0, 0)
>>> 2018-11-08 08:00:00-08:00
```
# Examples
You can download the 'example.py' file to see the functions in action.
# Contact
GitHub: @Buscedv
Edvard Busck-Nielsen 2020