Skip to main content

An implementation of a TTTime in Python.

Project description

TTTime Libraries

TTTime is a base 10 time representation. It is used to represent time in a way that is easy to understand and work with. Time is measured from 18:00:00 - 21/10/2020 UTC Standard Time (Day Zero).

Day Zero: 18:00:00 - 21/10/2020 UTC
1 TTT Hour = 1 Hour Standard Time
100 TTT Seconds in a TTT Minute
100 TTT Minutes in a TTT Hour
100 TTT Hours in a TTT Day
10 TTT Days in a TTT Month
10 TTT Months in a TTT Year

Benefits

  • Easy to understand and work with
  • No time zones or daylight savings time
  • No leap anything

Packages

  • JavaScript/TypeScript
  • Python
  • Rust - Implementation is missing some features, mainly interactions with standard time, it also is slightly buggy.
  • More coming soon!

API

This is the standard API for TTTime, some of the packages may lack some features or have slightly different implementations.

class TTTime:
    # Constructor
    method constructor(input: Date | TTTimePartial | string):
        if input is TTTimePartial:
            for each field in input:
                set field using setter methods
        else if input is string:
            convert string to Date and store as time since epoch
        else:
            store current time since epoch

    method toStandard() -> Date:
        convert TTTime milliseconds to standard Date object

    # Getter Methods
    method getYear() -> number:
        return year component from stored time

    method getMonth() -> number:
        return month component from stored time

    method getDay() -> number:
        return day component from stored time

    method getHour() -> number:
        return hour component from stored time

    method getMinute() -> number:
        return minute component from stored time

    method getSecond() -> number:
        return second component from stored time

    method getMillisecond() -> number:
        return millisecond component from stored time

    # Setter Methods
    method setYear(year: number):
        update year component in stored time

    method setMonth(month: number):
        validate month and update month component in stored time

    method setDay(day: number):
        validate day and update day component in stored time

    method setHour(hour: number):
        validate hour and update hour component in stored time

    method setMinute(minute: number):
        validate minute and update minute component in stored time

    method setSecond(second: number):
        validate second and update second component in stored time

    method setMillisecond(millisecond: number):
        validate millisecond and update millisecond component in stored time

    # Arithmetic Methods
    method add(time: TTTime | Date | TTTimePartial):
        add given time to stored time

    method subtract(time: TTTime | Date | TTTimePartial):
        subtract given time from stored time

    # Comparison Methods
    method isBefore(time: TTTime | Date | TTTimePartial) -> boolean:
        compare stored time with given time

    method isAfter(time: TTTime | Date | TTTimePartial) -> boolean:
        compare stored time with given time

    method isEqual(time: TTTime | Date | TTTimePartial) -> boolean:
        compare stored time with given time

    # Formatting Method
    method toString(format: string = '%Y-%m-%d %H:%M:%S') -> string:
        format stored time based on given format

    # Utility Method
    method toStandardMilliseconds() -> number:
        return stored time in milliseconds since epoch

Contributing

Contributions are welcome! Please open an issue or pull request if you have any suggestions or want to contribute at https://github.com/tonyaellie/tttime.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

tttime-1.0.5.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

tttime-1.0.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file tttime-1.0.5.tar.gz.

File metadata

  • Download URL: tttime-1.0.5.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tttime-1.0.5.tar.gz
Algorithm Hash digest
SHA256 aa44a9d73241ac04d05571393f6f693093e6eabcb3ff2cc6d3d7395bbf4cc83e
MD5 af1ab55e5881d2235cf5480137c3b8ce
BLAKE2b-256 1b68953ae6ffb429f625c5e2637d158d9d8dc4e135ebe3adc43c4619e907012e

See more details on using hashes here.

File details

Details for the file tttime-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: tttime-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tttime-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9e629c7d4d32bd107a1cda682342a8deb263a079aad09caca754c46ce5e325fd
MD5 178c1978a46e797cde2c9d33ee1925cf
BLAKE2b-256 267566c59e766c781016be26b742c7059e1129a5bc5e2d3afc185cd3d879ff2a

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