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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tttime-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 6632bd5882888cb62a1843526567623721bd3290db2ce993aac17460aaec21f8
MD5 ebcd65de3aef91f45170acabc85fd9ee
BLAKE2b-256 8f11905f356151e19823e7c60147f48986dcd5786d5f28e3c432943a6748ad3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tttime-1.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5a49468a89e5d4938d002e60251aa6518bd21910284affa0073db031759c8dfe
MD5 3a248d82de6fb17c9eeec2260a910b9a
BLAKE2b-256 311d300128f9e182b0e9b05493eb6b683b0529b650a633b14d9d2eb51db00890

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