timelab


Nametimelab JSON
Version 1.0 PyPI version JSON
download
home_pageNone
SummaryPython time engine.
upload_time2024-11-28 11:51:06
maintainerNone
docs_urlNone
authorSchkimansky
requires_pythonNone
licenseNone
keywords python time engine lab timelab datetime date time manager
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# TimeLab
This library handles everything related to time, Heres an example of how to use this library:

```python
from timelab import TimeSpan

timespan = TimeSpan(minutes=100)
print(timespan.seconds)  # Output: 0
print(timespan.minutes)  # Output: 100
print(timespan.hours)    # Output: 0

# Find total
print(timespan.total_seconds())  # Output: 6000
print(timespan.total_minutes())  # Output: 100
print(timespan.total_hours())    # Output: 1.6~

# Add time
print(TimeSpan(minutes=100) + TimeSpan(minutes=30))  # Output: TimeSpan(130 minutes)

# Subtract time
print(TimeSpan(minutes=100) - TimeSpan(minutes=30))  # Output: TimeSpan(70 minutes)

# Normalize time
# Normalize() will normalize the time format to make it more readable
print(TimeSpan(seconds=125).normalize())  # Output: TimeSpan(2 minutes, 5 seconds)
print(TimeSpan(hours=2.5).normalize())  # Output: TimeSpan(2 hours, 30 minutes)

# Get time as dictionary
print(TimeSpan(hours=2.5).as_dictionary())  # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}
print(TimeSpan(hours=2.5).as_dictionary())  # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}

# As datetime
print(TimeSpan(hours=2.5).as_datetime())  # Output: DateTime(2.5 hours)
```

And usage for datetime:

```python
from timelab import DateTime, TimeSpan

# Timestamp
print(DateTime.now().timestamp())  # Output format: Year-Month-Day

# Timestamp with custom format
print(DateTime.now().timestamp(time_format='Year: %Y, Month: %M, Day: %D'))  # Output format: Year: Year, Month: Month, Day: Day

# As timespan
print(DateTime.now().as_timespan())

# Add and subtract timespan to datetime
print(DateTime.now() + TimeSpan(minutes=30))
print(DateTime.now() - TimeSpan(minutes=30))

# Get difference between 2 datetimes
print(DateTime.now() - DateTime.now())  # Returns the difference as a timespan
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "timelab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, time, engine, lab, timelab, datetime, date, time, manager",
    "author": "Schkimansky",
    "author_email": "<ahmadchawla1432@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/6b/abaffef399821452e7d6d3a0f52848d5dc8b1d7eb2dc4bf0fe5df8fec775/timelab-1.0.tar.gz",
    "platform": null,
    "description": "\n# TimeLab\nThis library handles everything related to time, Heres an example of how to use this library:\n\n```python\nfrom timelab import TimeSpan\n\ntimespan = TimeSpan(minutes=100)\nprint(timespan.seconds)  # Output: 0\nprint(timespan.minutes)  # Output: 100\nprint(timespan.hours)    # Output: 0\n\n# Find total\nprint(timespan.total_seconds())  # Output: 6000\nprint(timespan.total_minutes())  # Output: 100\nprint(timespan.total_hours())    # Output: 1.6~\n\n# Add time\nprint(TimeSpan(minutes=100) + TimeSpan(minutes=30))  # Output: TimeSpan(130 minutes)\n\n# Subtract time\nprint(TimeSpan(minutes=100) - TimeSpan(minutes=30))  # Output: TimeSpan(70 minutes)\n\n# Normalize time\n# Normalize() will normalize the time format to make it more readable\nprint(TimeSpan(seconds=125).normalize())  # Output: TimeSpan(2 minutes, 5 seconds)\nprint(TimeSpan(hours=2.5).normalize())  # Output: TimeSpan(2 hours, 30 minutes)\n\n# Get time as dictionary\nprint(TimeSpan(hours=2.5).as_dictionary())  # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}\nprint(TimeSpan(hours=2.5).as_dictionary())  # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}\n\n# As datetime\nprint(TimeSpan(hours=2.5).as_datetime())  # Output: DateTime(2.5 hours)\n```\n\nAnd usage for datetime:\n\n```python\nfrom timelab import DateTime, TimeSpan\n\n# Timestamp\nprint(DateTime.now().timestamp())  # Output format: Year-Month-Day\n\n# Timestamp with custom format\nprint(DateTime.now().timestamp(time_format='Year: %Y, Month: %M, Day: %D'))  # Output format: Year: Year, Month: Month, Day: Day\n\n# As timespan\nprint(DateTime.now().as_timespan())\n\n# Add and subtract timespan to datetime\nprint(DateTime.now() + TimeSpan(minutes=30))\nprint(DateTime.now() - TimeSpan(minutes=30))\n\n# Get difference between 2 datetimes\nprint(DateTime.now() - DateTime.now())  # Returns the difference as a timespan\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python time engine.",
    "version": "1.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        " time",
        " engine",
        " lab",
        " timelab",
        " datetime",
        " date",
        " time",
        " manager"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d94145780a2e871a9f4c90f5c5135b704a7dddb7d7a48ad8f7f894694227681",
                "md5": "a50363c768c546951818ae6b2a5bdb1a",
                "sha256": "a296b4dcc82f21df5b81a8d398903a2a54bc15808297400f847a775b748a548d"
            },
            "downloads": -1,
            "filename": "timelab-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a50363c768c546951818ae6b2a5bdb1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6053,
            "upload_time": "2024-11-28T11:51:04",
            "upload_time_iso_8601": "2024-11-28T11:51:04.686186Z",
            "url": "https://files.pythonhosted.org/packages/7d/94/145780a2e871a9f4c90f5c5135b704a7dddb7d7a48ad8f7f894694227681/timelab-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "266babaffef399821452e7d6d3a0f52848d5dc8b1d7eb2dc4bf0fe5df8fec775",
                "md5": "341b378d6ffd0aef345b47f562d3fbf7",
                "sha256": "2719ecee39dc2ac7a1c90adc523e46c189082aaa9a4ef1b0ffc9cf8da58372aa"
            },
            "downloads": -1,
            "filename": "timelab-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "341b378d6ffd0aef345b47f562d3fbf7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5477,
            "upload_time": "2024-11-28T11:51:06",
            "upload_time_iso_8601": "2024-11-28T11:51:06.589395Z",
            "url": "https://files.pythonhosted.org/packages/26/6b/abaffef399821452e7d6d3a0f52848d5dc8b1d7eb2dc4bf0fe5df8fec775/timelab-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-28 11:51:06",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "timelab"
}
        
Elapsed time: 0.48214s