Skip to content

Add timezone_abbr property shortcut to tzname() #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down
185 changes: 56 additions & 129 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,139 +16,66 @@ jobs:
run: |
pip install pre-commit
pre-commit run --all-files
Linux:

Tests:
needs: Linting
runs-on: ubuntu-latest
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy3]

os: [Ubuntu, MacOS, Windows]
python-version: [3.6, 3.7, 3.8, pypy3]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade pip
run: |
source $HOME/.poetry/env
poetry run python -m pip install pip -U
- name: Install dependencies
run: |
source $HOME/.poetry/env
poetry install -vvv
- name: Test Pure Python
run: |
source $HOME/.poetry/env
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests
- name: Test
run: |
source $HOME/.poetry/env
poetry run pytest -q tests
poetry install
- uses: actions/checkout@v2

MacOS:
needs: Linting
runs-on: macos-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy3]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-fix-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade pip
run: |
source $HOME/.poetry/env
poetry run python -m pip install pip -U
- name: Install dependencies
run: |
source $HOME/.poetry/env
poetry install -vvv
- name: Test Pure Python
run: |
source $HOME/.poetry/env
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests
- name: Test
run: |
source $HOME/.poetry/env
poetry run pytest -q tests
Windows:
needs: Linting
runs-on: windows-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Get full python version
id: full-python-version
shell: bash
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and setup Poetry
run: |
Invoke-WebRequest https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -O get-poetry.py
python get-poetry.py --preview -y
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade pip
run: |
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry run python -m pip install pip -U
- name: Install dependencies
run: |
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry install -vvv
- name: Test Pure Python
run: |
$env:Path += ";$env:Userprofile\.poetry\bin"
$env:PENDULUM_EXTENSIONS = "0"
poetry run pytest -q tests
- name: Test
run: |
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry run pytest -q tests
- name: Install poetry
shell: bash
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python get-poetry.py --preview -y
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"

- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

- name: Upgrade pip
shell: bash
run: |
poetry run python -m pip install pip -U

- name: Install dependencies
shell: bash
run: poetry install -vvv

- name: Test Pure Python
shell: bash
run: |
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests

- name: Test
shell: bash
run: |
poetry run pytest -q tests
3 changes: 3 additions & 0 deletions build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ for PYBIN in /opt/python/cp3*/bin; do
if [ "$PYBIN" == "/opt/python/cp34-cp34m/bin" ]; then
continue
fi
if [ "$PYBIN" == "/opt/python/cp35-cp35m/bin" ]; then
continue
fi
rm -rf build
"${PYBIN}/python" $HOME/.poetry/bin/poetry build -vvv
done
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/attributes_properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Pendulum gives access to more attributes and properties than the default ``datet
# Gets the timezone name
>>> pendulum.now().timezone_name

# Gets the timezone abbreviation
>>> pendulum.now().timezone_abbr

# Indicates if daylight savings time is on
>>> dt = pendulum.datetime(2012, 1, 1, tz='America/Toronto')
>>> dt.is_dst()
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ so things aren't always as they seem.
'2012-09-05 23:26:11'
>>> first.timezone_name
'America/Toronto'
>>> first.timezone_abbr
'EDT'
>>> second.to_datetime_string()
'2012-09-05 20:26:11'
>>> second.timezone_name
'America/Vancouver'
>>> second.timezone_abbr
'PDT'

>>> first == second
True
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/instantiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ There is also the `now()` method.
>>> now_in_london_tz = pendulum.now('Europe/London')
>>> now_in_london_tz.timezone_name
'Europe/London'
>>> now_in_london_tz.timezone_abbr
'BST'
```

To accompany `now()`, a few other static instantiation helpers exist to create known instances.
Expand Down
Loading