Skip to main content

ym

Data type that handles year and month values.

Build Status

Usage

Import

from ym import ym

Initialize

from year, month

ym(2020, 4)  #=> ym(2020, 4)

from current month

ym.current()  #=> ym(2020, 7)

from string

ym.parse("2020-04")  #=> ym(2020, 4)

from date or datetime object

from datetime import date

ym.parse(date.today())  #=> ym(2020, 7)

Get year, month

current = ym.current()  #=> ym(2020, 7)
current.y  #=> 2020
current.m  #=> 7

Add, Sub

ym(2020, 4) + 10  #=> ym(2021, 2)
ym(2020, 4) - 10  #=> ym(2019, 6)
ym(2020, 7) - ym(2020, 4)  #=> 3

Compare

ym(2020, 7) < ym(2020, 4)  #=> False
ym(2020, 7) > ym(2020, 4)  #=> True
ym(2020, 7) == ym(2020, 4)  #=> False

Range

list(ym(2020, 4).to(2020, 7))  #=> [ym(2020, 4), ym(2020, 5), ym(2020, 6)]
current = ym.current()  #=> ym(2020, 7)
list(current.to(current + 6))  #=> [ym(2020, 7), ym(2020, 8), ym(2020, 9), ym(2020, 10), ym(2020, 11), ym(2020, 12)]

Release files for ym 1.0.2

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

Source distribution (sdist)

Source distribution for ym 1.0.2
File Size Uploaded
ym-1.0.2.tar.gz 1.9 kB Details

Release files / ym-1.0.2.tar.gz

Download URL ym-1.0.2.tar.gz
Size 1.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c10f7e6f39b82bd46ce1caf3f05f2e060b44f9e951db514ad430123bcbc394b8
BLAKE2b-256 checksum
How to use checksums
5a616dbf6a5e0c9a25422d924e6d41eb9bf1a1ab9b0c21c15215a912ef27b1e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

1 release file

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