Skip to main content

Collection of functions and other, including functional approach to dates (as ISO-DATE string)

Project description

funner

Includes:

  • datefun - Functional approach to date manipulations
  • textparse - functions for string to data manipulations
  • textgen - functions for generating text from text template using data (Jinja2 helps here)
  • filefun - functions for file manipulation
  • packfun - functions for finding and loading resources from packages
  • storable - Base class for serializable objects

install

pip install funner

(or pip3 or pipx)

Needs python 3.10 (because of type hints/annotations with pipes)

usage

from funner import datefun

print(datefun.dt_add_months("2025-02-28", -1)) # outputs 2025-01-31
print(datefun.dt_add_months("2025-02-28", 1, False)) # outputs 2025-03-28

datefun

Date is string. In ISO format (Y-M-D). Mostly it came from database.

Now we want some manipulations and return again ISO date as string.

Conversion functions:

  • dt_make(year: int, month: int, day: int) -> str
  • dt_from_object(obj: datetime) -> str

Date (string) output functions:

  • dt_month_start(iso_date: str) -> str
  • dt_month_end(iso_date: str) -> str
  • dt_week_start(iso_date: str, week_start_monday: bool = True) -> str
  • dt_week_end(iso_date: str, week_start_monday: bool = True) -> str
  • dt_quarter_start(iso_date: str) -> str
  • dt_quarter_end(iso_date: str) -> str
  • dt_semiyear_start(iso_date: str) -> str
  • dt_semiyear_end(iso_date: str) -> str
  • dt_year_start(iso_date: str) -> str
  • dt_year_end(iso_date: str) -> str
  • dt_add_years(iso_date: str, many_years: int, interpret_0228_as_monthend: bool = True) -> str
  • dt_add_months(iso_date: str, many_months: int, stay_in_month_end: bool = True) -> str
  • dt_add_days(iso_date: str, many_days: int) -> str
  • dt_easter(year: int) -> str
  • dt_easter_gauss(year: int) -> str
  • dt_good_friday(year: int) -> str
  • dt_pentecost(year: int) -> str
  • dt_add_week(iso_date: str, many_weeks: int) -> str
  • dt_add_quarter(iso_date: str, many_quarters: int, stay_in_month_end: bool = True) -> str
  • dt_add_semiyear(iso_date: str, many_semiyear: int, stay_in_month_end: bool = True) -> str

Boolean output functions:

  • is_leap_year(year_or_date: int | str) -> bool
  • is_valid_date(iso_date: str) -> bool

Integer output functions:

  • int_days_in_month(iso_date: str) -> int

textparse

Conversion functions:

  • dict_from_yaml
  • list_from_yaml

textgen

Conversion functions:

  • generate_from_string
  • generate_from_file

packfun

Package/module digging functions:

  • read_content_of_package_file
  • copy_from_package_to_file
  • prepare_function

filefun

Context Manager:

  • open_with_missing_dirs

Text-reading function:

  • read_content_of_file

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

funner-0.0.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file funner-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: funner-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for funner-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c1208272f40a0bf85d4f542fc3035c2598e59c60f98683577f59467aed88698
MD5 e2affd11a45958aad315f10bbe6579b9
BLAKE2b-256 08a48b185c157c27197b4615ab10bfabb8540f23ddd23dc037286765e4367407

See more details on using hashes here.

Supported by

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