Skip to main content

Handles date time manipulation with simplicity

Project description

Tcalendar and Ttime

This project provides two classes, Tcalendar and Ttime, which allow for easy manipulation and handling of calendar dates and times in Python.

Introduction

  • Tcalendar: This class represents a date on the calendar. It allows for the representation and manipulation of dates, including addition and subtraction of days, comparison of dates, and conversion to and from string representation.

  • Ttime: This class represents a specific time of day. It allows for the representation and manipulation of time, including addition and subtraction of seconds, comparison of times, and conversion to and from string representation.

Features

  • Tcalendar

    • Creation of dates based on year, month, and day.
    • Leap year detection.
    • Getting the name of the month.
    • Finding the maximum number of days in a month.
    • Determining the day of the week.
    • Generating calendar pages.
    • Calculating the next and previous days.
    • Getting today's date.
    • Sorting dates.
  • Ttime

    • Creation of times based on hour, minute, and second.
    • Switching between 12-hour and 24-hour formats.
    • Getting the current time.
    • Sorting times.
  • Tcalendar_time

    • Combines features of Tcalendar and Ttime classes.
    • Creation of datetime objects with date and time components.
    • Addition and subtraction of datetime objects.
    • Comparison of datetime objects.
    • Conversion to and from string representation.

Usage

Here's how you can use these classes in your Python code:

from tcalendar_ttime import Tcalendar, Ttime

# Create a Tcalendar instance
date = Tcalendar(2024, 5, 24)

# Print the date
print(date)  # Output: 2024-05-24

# Create a Ttime instance
mytime = Ttime(13, 30, 0)
mytime.format12() # 12 hour formatting time

# Print the time
print(mytime)  # Output: 01:30:00 PM

Installation

You can install the package using pip:

pip install tcalendar-ttime

Examples

# Example: Adding days to a date
date = Tcalendar(2024, "May", 24)
new_date = date + 7

# Example: Sorting a list of dates
dates = [date, new_date, Tcalendar.today()]
sorted_dates = Tcalendar.sort(dates)

# Create a Tcalendar_time instance
datetime = Tcalendar_time(2024, 5, 24, 1, 30, 0)

# Print the datetime
print(datetime)  # Output: 2024-05-24 01:30:00 PM

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

tacalendar_ttime-0.2.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file tacalendar_ttime-0.2.tar.gz.

File metadata

  • Download URL: tacalendar_ttime-0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.13

File hashes

Hashes for tacalendar_ttime-0.2.tar.gz
Algorithm Hash digest
SHA256 cbb4e96023d3ec24bbb40a43a18e899d3fd7e71594923e4c4990f62dbe1340ff
MD5 a693ee8c2656549d65f5c2dc0b27f7bd
BLAKE2b-256 9803e2a8ede4bb72591f2072515ad117e4747a9a2118fde849f5c1730ea65a0a

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