[PR #696] [MERGED] Add Pendulum to Date and Time libraries #2734

Closed
opened 2026-04-15 09:05:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vinta/awesome-python/pull/696
Author: @sdispater
Created: 8/16/2016
Status: Merged
Merged: 10/21/2016
Merged by: @vinta

Base: masterHead: add-pendulum


📝 Commits (2)

  • 9416213 Adds Pendulum to Date and Time libraries
  • a3adcdb Change list order

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 README.md (+1 -0)

📄 Description

Why this framework/library/software/resource is awesome?

Pendulum aims at making Python datetimes easy. It fixes the flaw of the existing libraries (especially Arrow) while providing a more explicit API. Here are some examples:

import pendulum

now = pendulum.now('Europe/Paris')

# Changing timezone
now.in_timezone('America/Toronto')

# Default support for common datetime formats
now.to_iso8601_string()

# Shifting time
now.add(days=2)

It improves the native timedelta type:

it = pendulum.interval(days=15)

# More properties
it.weeks
it.hours

# Handy methods
it.in_hours()
360
it.in_words(locale='en_us')
'2 weeks 1 day'

It brings its own Period class, which is a datetime-ware timedelta:

dt1 = pendulum.now()
dt2 = dt1.add(days=3)

# A period is the difference between 2 instances
period = dt2 - dt1

period.in_weekdays()
period.in_weekend_days()

# A period is iterable
for dt in period:
    print(dt)

And finally, it improves timezones manipulation by handling normalization properly and shifting time around DST transition time:

import pendulum

pendulum.create(2013, 3, 31, 2, 30, 0, 0, 'Europe/Paris')
#2:30 for the 31th of March 2013 does not exist
# so pendulum will return the actual time which is 3:30+02:00
'2013-03-31T03:30:00+02:00'

in_utc = pendulum.create(2013, 3, 31, 0, 59, 59, 999999)
tz = pendulum.timezone('Europe/Paris')
in_paris = tz.convert(in_utc)
'2013-03-31T01:59:59.999999+01:00'

# Shifting time
in_paris = in_paris.add(microseconds=1)
'2013-03-31T03:00:00+02:00'
in_paris.subtract(microseconds=1)
'2013-03-31T01:59:59.999999+01:00'

For the rest you can check out the official documentation: https://pendulum.eustace.io/docs/

Anyone who agrees with this pull request could vote for it by adding a 👍 to it, and usually, the maintainer will merge it when votes reach 20.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vinta/awesome-python/pull/696 **Author:** [@sdispater](https://github.com/sdispater) **Created:** 8/16/2016 **Status:** ✅ Merged **Merged:** 10/21/2016 **Merged by:** [@vinta](https://github.com/vinta) **Base:** `master` ← **Head:** `add-pendulum` --- ### 📝 Commits (2) - [`9416213`](https://github.com/vinta/awesome-python/commit/94162133c4ceaea416cbf3eba7ce5e8394da2c64) Adds Pendulum to Date and Time libraries - [`a3adcdb`](https://github.com/vinta/awesome-python/commit/a3adcdb118eb28e6baad8e37367b319914a8b3bd) Change list order ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) </details> ### 📄 Description ## Why this framework/library/software/resource is awesome? Pendulum aims at making Python datetimes easy. It fixes the flaw of the existing libraries (especially Arrow) while providing a more explicit API. Here are some examples: ``` python import pendulum now = pendulum.now('Europe/Paris') # Changing timezone now.in_timezone('America/Toronto') # Default support for common datetime formats now.to_iso8601_string() # Shifting time now.add(days=2) ``` It improves the native `timedelta` type: ``` it = pendulum.interval(days=15) # More properties it.weeks it.hours # Handy methods it.in_hours() 360 it.in_words(locale='en_us') '2 weeks 1 day' ``` It brings its own `Period` class, which is a datetime-ware `timedelta`: ``` python dt1 = pendulum.now() dt2 = dt1.add(days=3) # A period is the difference between 2 instances period = dt2 - dt1 period.in_weekdays() period.in_weekend_days() # A period is iterable for dt in period: print(dt) ``` And finally, it improves timezones manipulation by handling normalization properly and shifting time around DST transition time: ``` python import pendulum pendulum.create(2013, 3, 31, 2, 30, 0, 0, 'Europe/Paris') #2:30 for the 31th of March 2013 does not exist # so pendulum will return the actual time which is 3:30+02:00 '2013-03-31T03:30:00+02:00' in_utc = pendulum.create(2013, 3, 31, 0, 59, 59, 999999) tz = pendulum.timezone('Europe/Paris') in_paris = tz.convert(in_utc) '2013-03-31T01:59:59.999999+01:00' # Shifting time in_paris = in_paris.add(microseconds=1) '2013-03-31T03:00:00+02:00' in_paris.subtract(microseconds=1) '2013-03-31T01:59:59.999999+01:00' ``` For the rest you can check out the official documentation: https://pendulum.eustace.io/docs/ ## Anyone who agrees with this pull request could vote for it by adding a :+1: to it, and usually, the maintainer will merge it when votes reach **20**. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 09:05:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-python#2734