Skip to main content

Data type that handles year and month values.

Project description

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)]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ym-1.0.2.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file ym-1.0.2.tar.gz.

File metadata

  • Download URL: ym-1.0.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ym-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c10f7e6f39b82bd46ce1caf3f05f2e060b44f9e951db514ad430123bcbc394b8
MD5 eca095212b6b1b52d936bb4f8da4ae4f
BLAKE2b-256 5a616dbf6a5e0c9a25422d924e6d41eb9bf1a1ab9b0c21c15215a912ef27b1e5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page