Package: iso-week-date
ISO Week Dateiso-week-dateis a toolkit to work with strings representingISO Week datein two formats, namely:Week formatYYYY-WNN(corresponding to the date format%Y-W%V)Week date formatYYYY-WNN-D(corresponding to the date format%Y-W%V-%u)(where YYYY represents the year, W is a literal, NN represents the week number, and D represents the day of the week)In a nutshell it provides:IsoWeekandIsoWeekDateclasses implementing a series of methods to work with ISO Week (Date) formats and avoiding the pitfalls of going back and forth between string, date and datetime python objectspandasandpolarsfunctionalities to work with series of ISO Week datesDocumentation|Source CodeInstallationiso-week-dateis published as a Python package onpypi, and it can be installed with pip, or directly from source using git, or with a local clone:pip(suggested):python-mpipinstalliso-week-datepip + source/git:python-mpipinstallgit+https://github.com/FBruzzesi/iso-week-date.gitlocal clone:gitclonehttps://github.com/FBruzzesi/iso-week-date.gitcdiso-week-date
python-mpipinstall.DependenciesTo work withIsoWeekandIsoWeekDateclasses, no additional dependency is required.pandasandpolarsfunctionalities require the installation of the respective libraries.Getting StartedAvailable featuresThis is a high level overview of the features provided by theiso-week-datepackage.TheIsoWeekandIsoWeekDateclasses provide the following functionalities:Parsing from string, date and datetime objectsConversion to string, date and datetime objectsComparison operations betweenIsoWeek(respIsoWeekDate) objectsAddition withintandtimedeltatypesSubtraction withint,timedeltaandIsoWeek(respIsoWeekDate) typesRange between twoIsoWeek(resp.IsoWeekDate) objects__next__method to generate the nextIsoWeek(resp.IsoWeekDate) objectIsoWeekunique methods/features:daysproperties that lists the dates in the given weeknthmethod to get thenthday of the week as dateinoperator andcontainsmethod to check if a (iterable of) week(s), string(s) and/or date(s) is contained in the given weekweeksoutmethod to generate a list of weeks that aren_weeksafter the given weekAddition and subtraction withintdefaults to adding/subtracting weeksIsoWeekDateunique methods/features:dayproperty that returns the weekday as integerisoweekproperty that returns the ISO Week of the given date (as string)daysoutmethod to generate a list of dates that aren_daysafter the given dateAddition and subtraction withintdefaults to adding/subtracting dayspandas_utilsandpolars_utilsmodules provide functionalities to work with and move back and forth withseriesof ISO Week date formats.In specific both modules implements the following functionalities:datetime_to_isoweekanddatetime_to_isoweekdateto convert a series of datetime objects to a series of ISO Week (date) stringsisoweek_to_datetimeandisoweekdate_to_datetimeto convert a series of ISO Week (date) strings to a series of datetime objectsis_isoweek_seriesandis_isoweekdate_seriesto check if a string series values match the ISO Week (date) formatQuickstartTo get started withIsoWeekandIsoWeekDateclasses please refer to thequickstartdocumentation section.To check examples on how to work withpandasandpolarsfunctionalities please refer to thedataframe modulesdocumentation section.Custom offsetOne of the main reason for this library to exist is the need and the flexibility to work with custom offsets, i.e. to be able to add/subtract a custom offset (astimedelta) to the default ISO Week start and given date, and get a "shifted" week.This feature is available both in theIsoWeekandIsoWeekDateclasses and the dataframe functionalities.To check an example see theworking with custom offsetsection.ContributingPlease read thecontributing guidelinesin the documentation site.LicenseThe project has aMIT Licence.