timedelta

Defines the BSTimedelta class for representing time durations.

This module provides a timedelta object that is a subclass of the standard datetime.timedelta, extending it with custom string formatting capabilities, including support for Nepali numerals.

class bikram_sambat.bs_timedelta.BSTimedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)[source]

Bases: timedelta

Represents a duration, the difference between two dates or times.

BSTimedelta is a subclass of the standard datetime.timedelta and supports all the same operations and arguments. Its main enhancement is a more descriptive __str__ method that can optionally display durations using Nepali numerals. All arithmetic operations will correctly return a new BSTimedelta instance.

Parameters:
  • days (float) – Number of days. Defaults to 0.

  • seconds (float) – Number of seconds. Defaults to 0.

  • microseconds (float) – Number of microseconds. Defaults to 0.

  • milliseconds (float) – Number of milliseconds. Defaults to 0.

  • minutes (float) – Number of minutes. Defaults to 0.

  • hours (float) – Number of hours. Defaults to 0.

  • weeks (float) – Number of weeks. Defaults to 0.

Example

>>> delta = BSTimedelta(days=5, hours=10)
>>> print(delta)
5 days, 10:00:00
>>> print(delta.__str__(use_nepali_digits=True))
५ दिन, १०:००:००