All Projects → shinux → Pytime

shinux / Pytime

Licence: mit
PyTime is an easy-use Python module which aims to operate date/time/datetime by string.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytime

Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+1316.43%)
Mutual labels:  datetime, date-time
vscode-insertdatestring
An extension for Visual Studio Code that provides a configurable command for inserting the current date and time
Stars: ✭ 58 (-58.57%)
Mutual labels:  datetime, date-time
Eztime
ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
Stars: ✭ 173 (+23.57%)
Mutual labels:  datetime, date-time
material-ui-datetimepicker
[UNMAINTAINED] Wrapper for Material UI Date and Time picker components
Stars: ✭ 32 (-77.14%)
Mutual labels:  datetime, date-time
Pdd
📅 Tiny date, time diff calculator with piggybacked timers
Stars: ✭ 218 (+55.71%)
Mutual labels:  datetime, date-time
Calendarview
An Easy to Use Calendar for iOS (Swift 5.0)
Stars: ✭ 429 (+206.43%)
Mutual labels:  datetime, date-time
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+875%)
Mutual labels:  datetime
Dateutil
Useful extensions to the standard Python datetime features
Stars: ✭ 1,706 (+1118.57%)
Mutual labels:  datetime
Angular Datetime
A directive to add the behavior of datetime input on unsupported browsers.
Stars: ✭ 95 (-32.14%)
Mutual labels:  datetime
Graphql Java Datetime
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.
Stars: ✭ 89 (-36.43%)
Mutual labels:  datetime
Anytime
Anything to POSIXct or Date Converter
Stars: ✭ 137 (-2.14%)
Mutual labels:  datetime
Persiandate4mysql
pDate is a Gregorian / Jalali(Shamsi) date convertor functions for MySQL 5.1+
Stars: ✭ 131 (-6.43%)
Mutual labels:  datetime
Human time
Ruby time and date comparisons for humans
Stars: ✭ 113 (-19.29%)
Mutual labels:  datetime
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (-25.71%)
Mutual labels:  datetime
Moment Range
Fancy date ranges for Moment.js
Stars: ✭ 1,639 (+1070.71%)
Mutual labels:  date-time
Datetime Fortran
Date and time manipulation for modern Fortran
Stars: ✭ 95 (-32.14%)
Mutual labels:  datetime
Libfaketime
libfaketime modifies the system time for a single application
Stars: ✭ 1,932 (+1280%)
Mutual labels:  datetime
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (-34.29%)
Mutual labels:  datetime
Calendar
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (-19.29%)
Mutual labels:  datetime
Pyjson tricks
Extra features for Python's JSON: comments, order, numpy, pandas, datetimes, and many more! Simple but customizable.
Stars: ✭ 131 (-6.43%)
Mutual labels:  datetime

PyTime

Build Status PyPI version Supported Python versions

PyTime is an easy-use Python module which aims to operate date/time/datetime by string.

PyTime allows you using nonregular datetime string to generate and calculate datetime at most situation.

It Also provides you some simple useful methods for getting datetime you want.

Install

pip install pytime

Sample Usage

Calculate datetime all by string, accept unit for short or overall length, support out of order or in capital unit:

>>>from pytime import pytime
>>>
>>>pytime.before('2015.5.17', '2years 3mon 23week 3d 2hr')     # 2years 3months 23weeks 3days 2hours before 2015.5.17
datetime.datetime(2012, 9, 5, 22, 0)
>>>
>>>pytime.after(pytime.tomorrow('15.5.17'), '23month3dy29minu')   # 23months 3days 29minutes after 2015-5-17's next day
datetime.datetime(2017, 4, 21, 0, 29)

Parse nonregular datetime string to datetime:

>>>pytime.parse('April 3rd 2015')
datetime.date(2015, 4, 3)
>>>pytime.parse('Oct, 1st. 2015')
datetime.date(2015, 10, 1)
>>>pytime.parse('NOV21th2015')
datetime.date(2015, 11, 21)
>>>
>>>pytime.parse('2015517')
datetime.date(2015, 5, 17)
>>>
>>>pytime.parse('5/17/15')
datetime.date(2015, 5, 17)
>>>
>>>pytime.parse('92-11-2')
datetime.date(1992, 11, 2)
>>>
>>>pytime.parse(1432310400)          # support datetimestamp for all function
datetime.datetime(2015, 5, 23, 0, 0)

Calculate week and month in a easy way. Normally we want to use these binate date in script, from Monday to next Monday which means 00:00:00-23:59:59, and Month from 1st to next 1st in the same way, but if you want clean date interval, you could set pytime.next_week(clean=True) to get the clean date for next week etc.

>>>pytime.this_week()
(datetime.date(2015, 5, 11), datetime.date(2015, 5, 18))

>>>pytime.next_week('2015-6-14')                         # 2015-6-14's next week for script
(datetime.date(2015, 6, 15), datetime.date(2015, 6, 23))

>>>pytime.last_week(pytime.mother(2013), True)           # 2013 Mother's Day's last week
(datetime.date(2013, 5, 13), datetime.date(2013, 5, 20))

>>>pytime.next_month('2015-10-1')
(datetime.date(2015, 11, 1), datetime.date(2015, 12, 1))

Pytime support calculate timedelta by string even between date and datetime, merely set the date to that day's midnight:

>>>pytime.count('2015-5-17 23:23:23', pytime.tomorrow())
datetime.timedelta(1, 84203)

Get common festivals for designated year:

>>>pytime.father()              # Father's Day
datetime.date(2015, 6, 21)
>>>
>>>pytime.mother(2016)          # 2016 Mother's Day
datetime.date(2016, 5, 8)
>>>
>>>pytime.easter(1999)          # 1999 Easter
datetime.date(1999, 4, 4)
>>>pytime.vatertag(2020)        # Fater's Day in Germany
datetime.date(2020, 5, 21)

Get days between two date.

>>>pytime.days_range('2015-5-17', '2015-5-23')
[datetime.date(2015, 5, 23),
 datetime.date(2015, 5, 22),
 datetime.date(2015, 5, 21),
 datetime.date(2015, 5, 20),
 datetime.date(2015, 5, 19),
 datetime.date(2015, 5, 18),
 datetime.date(2015, 5, 17)]

...

and other useful methods.

Contributors

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].