Skip to main content
Latest PyPI version Number of PyPI downloads Test bda.calendar.base

Convinience for Datetime handling in combination with Zope

bda.calendar.base contains functions adressing programmers all-day tasks not (or only partly) covered by pythons datetime or zopes DateTime.

Major part of these function is timezone aware. Also ist easy to deal with timezones. An TimezoneFactory can be provided in the specific application to i.e. be aware of the users timezone (i.e. in case of webapps).

calculators

CWof(date)

the calendar week number of a date.

firstDayOfCW(year, cw, tzinfo=None)

first day of a numbered calendar week

daysOfWeek(year, cw, tzinfo=None)

yields 7 datetimes of the given calendar week

numberOfDaysInYear(dt)

calculates number of days of the given datetimes year

numberOfDaysInMonth(dt)

calculates number of days of the given datetimes month

daysOfMonth

yields all days as datetimes of the given month

hoursOfDay(year, month, day, tzinfo=None)

yields all hours of a day as datetimes

isSameDay(first, second)

detects if two dates are the same day. bool.

converter

dt2DT(dt)

Convert Python’s datetime to Zope’s DateTime. Acts timezone-aware.

DT2dt(DT)

Convert Zope’s DateTime to Pythons’s datetime. Acts timezone-neutral, outcome is on UTC.

dt2UTCString(dt)

build a ‘-’ separated string from the datetime timetuple as UTC.

dtFromUTCString(utcstr)

build datetime from timetuple UTC string.

dt2epochday(dt)

Number of days since epoch. timezone gets a problem here, we need to normalize all to GMT to make it recognize the same day even if it a different timezone: i.e. 2008-05-01T00:00:00+02:00 (CEST)

inspector

All functions are using the timezoneAdjuster (see below). therefore a context is passed

dtYear(dt, context=None):

year of datetime.

dtMonth(dt, context=None)

month of datetime.

dtDay(dt, context=None)

day of datetime.

dtHour(dt, context=None)

hour of datetime.

dtMinute(dt, context=None)

minute of datetime.

dtWeekday(dt, context=None)

Weekday of datetime.

pyDt

Detect wether dt is instance of datetime object.

recurring

Simple recurring features. for more sophisticated recurring feature refer to dateutils.rrule

recueDays(start, until, recuemode, offset)

Generates list of recue days.

timezone

Dealing with timezones is always pain. With these common features it get less pain. Using ZCA where registering a common TimezoneFactory using the computers system timezone. It is used by the timezoneAdjuster. If you register a more specific TimezoneFactory following its simple interface - its just a callable - , you can implement user configurated multi-timezone aware applications. This is all based on pytz, because pytz just works.

ServerTimezoneFactory(context)

The timezone of the server (current computer). You never need to use this directly.

timezoneAdjuster(context, dt)

New datetime with given timezone. Given datetime cant be naive!

tzawarenow()

timezone aware now datetime using utc timezone. if you need the current timezone adjust it.

Contributors

Changes

2.0.0 (2026-10-31)

  • Fix numberOfDaysInYear. It called isLeapYear, which only Zope’s DateTime provides, and failed for datetime objects. This also broke yearly recurring in recueDays. [rnix]

  • Replace the deprecated datetime.utcnow in tzawarenow. Behaviour unchanged. [rnix]

  • Declare DateTime as dependency. bda.calendar.base.converter and bda.calendar.base.recurring import it. [rnix]

  • Drop the Python 2 remnants: implicit relative imports in bda.calendar.base.inspector, bda.calendar.base.recurring and bda.calendar.base.timezone. These modules were not importable on Python 3. [rnix]

  • Add tests. Use pytest as test runner. [rnix]

  • Sort the imports with ruff (one per line, from imports first, no sections) and format the code with ruff format (90 characters per line, single quotes). [rnix]

  • Add Makefile (mxmake) with qa.ruff, qa.test and qa.coverage domains, pin the ruff configuration in pyproject.toml and add a GitHub Actions test workflow. [rnix]

  • Move the changelog from README.rst to CHANGES.rst and the license to LICENSE.rst. [rnix]

  • Refactor package layout to use pyproject.toml and implicit namespace packages. [rnix]

  • Drop Python 2 support. Python >= 3.10 is required. [rnix]

1.2.5 (2022-12-05)

  • Try again to release wheel with zest.releaser. [rnix]

1.2.4 (2022-12-05)

  • Release wheel. [rnix]

1.2.3

  • Remove superfluous import. [rnix, 2020-08-12]

1.2.2

  • conditional ZCML for pyramid and zope. [rnix, 2011-11-16]

License

Copyright (c) 2008-2022, BlueDynamics Alliance, Austria All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the BlueDynamics Alliance nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for bda.calendar.base 2.0.0

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

Source distribution (sdist)

Source distribution for bda.calendar.base 2.0.0
File Size Uploaded Provenance Actions
bda_calendar_base-2.0.0.tar.gz 11.9 kB Without provenance Details for bda_calendar_base-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bda.calendar.base 2.0.0
File Interpreter ABI Platform Actions
bda_calendar_base-2.0.0-py3-none-any.whl Python 3 none any Details for bda_calendar_base-2.0.0-py3-none-any.whl

Total release size: 27.0 kB

Release files / bda_calendar_base-2.0.0.tar.gz

Download URL bda_calendar_base-2.0.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
17f0b55694f9b8ef2dd4c5df64f5c6910d9c14b4fb61e80d458d0da2e317fe03
BLAKE2b-256 checksum
How to use checksums
418c970aec4ef2befa92782ec0fc32225a8c59c0cccb9741d378d249db2f5c92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / bda_calendar_base-2.0.0-py3-none-any.whl

Download URL bda_calendar_base-2.0.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f58e77cdae3e5c3dbf835e6e98c1e582fadccc5f9da21fa75d3e6c8e34858ba6
BLAKE2b-256 checksum
How to use checksums
8e4f2f04493d9b1108fd6125fb27e34dbd8640b6c55aafe5327cc1bb40cab23e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for bda.calendar.base 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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