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.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tttime-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 0b599f78388ed32314135961c855103d3e72301d7dacd32e9e2ef4f0ff6530de
MD5 662dafa6bf391fad87a8d1c7f3f604cb
BLAKE2b-256 7f2f101ab9ab492ca3ea5fac602392db7d20a8f1ab48bc371da0a630c72f4b94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tttime-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 30850f39f24c53e1b8a10ea538abfd1f6201c363750dd1b7f50dd2766d8775ed
MD5 70e818dee77c506012b89102ba7b7bda
BLAKE2b-256 8a0d6daf3f5ab0d402669525fb59d174e805962c812797145220eee8ac5f1e5b

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