sometime


Namesometime JSON
Version 1.2.2 PyPI version JSON
download
home_page
SummaryGet timestamp, formatted date, and perform date/time operations.
upload_time2023-01-23 17:59:12
maintainer
docs_urlNone
authorRodney Maniego Jr.
requires_python>=3.10
licenseLICENSE.txt
keywords date time timestamp utc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sometime
Get timestamp, formatted date, and perform date/time operations.

## Official Release
**Sometime** v1.2.0

`pip install sometime -U`

## Basic Usage

```python
from sometime import Sometime
```

```python
# Default initialization
ts = Sometime()

# Custom initialization
ts = Sometime(1650614778, utc=True)

# Set timestamp in seconds
ts.timestamp(seconds)
ts["timestamp"] = seconds

# Set date/time based on date/time string
# https://help.gnome.org/users/gthumb/stable/gthumb-date-formats.html.en"
ts.from_iso("2022-04-22", "%Y-%m-%d")
print("Timestamp:", ts.timestamp())
```

# Get Unix Timestamp
```python
print("Timestamp:", ts.timestamp())
```

# Get current Unix Timestamp
```python
print("Current Timestamp:", ts.now())
```

# Add or subtract years
```python
ts = Sometime(seconds)
ts.year(years=-25)
ts.year(years=100)
print("Year:", ts.year())
print("Year:", ts["%Y"])
```

# Get name of the month
```python
ts = Sometime(seconds)
ts.name_of_month()
print("Date of the Month:", ts.name_of_month())
```

# Add or subtract months
```python
ts = Sometime(seconds)
ts.month(months=-1)
ts.month(months=12)
print("Month:", ts.month())
```

# Add or subtract days
```python
ts = Sometime(seconds)
ts.day(days=-7)
ts.day(days=14)
print("Day:", ts.day())
```

# Add or subtract hours
```python
ts = Sometime(seconds)
ts.hour(hours=-8)
ts.hour(hours=24)
hour = ts.hour()
print("Hour:", ts.hour())
```

# Add or subtract minutes
```python
ts = Sometime(seconds)
ts.minute(minutes=-5)
ts.minute(minutes=30)
minute = ts.minute()
print("Minute:", ts.minute())
```

# Add or subtract seconds
```python
ts = Sometime(seconds)
ts.second(seconds=-1)
ts.second(seconds=30)
second = ts.second()
print("Second:", ts.second())
```

# Get if AM/PM
```python
ts = Sometime(seconds)
ts.period()
print("Period:", ts.period())
```

# Get the Day of the Week
```python
ts = Sometime(seconds)
print("Day of the Week:", ts.day_of_week())
```

# Add or subtract to date/time
```python
ts = Sometime(seconds)
print("Timestamp:", ts.timestamp())
ts.add(years=1, months=2, days=3, hours=4, minutes=5, seconds=6)
print("Timestamp:", ts.timestamp())
```

# Format date/time into string representation
```python
ts = Sometime(seconds)
print("Timestamp:", ts.custom("%Y-%m-%d %H:%M:%S %p"))
```

# Get yesterday's on custom formatting
```python
ts = Sometime(seconds)
print("Yesterday:", ts.yesterday("%Y-%m-%d %H:%M:%S %p"))
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sometime",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "date,time,timestamp,utc",
    "author": "Rodney Maniego Jr.",
    "author_email": "rodney.maniegojr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/93/3c/49f636b7856cf2d90c429e5d838f64feaa609e4cf4a9f5b8edf71674ddbc/sometime-1.2.2.tar.gz",
    "platform": null,
    "description": "# sometime\nGet timestamp, formatted date, and perform date/time operations.\n\n## Official Release\n**Sometime** v1.2.0\n\n`pip install sometime -U`\n\n## Basic Usage\n\n```python\nfrom sometime import Sometime\n```\n\n```python\n# Default initialization\nts = Sometime()\n\n# Custom initialization\nts = Sometime(1650614778, utc=True)\n\n# Set timestamp in seconds\nts.timestamp(seconds)\nts[\"timestamp\"] = seconds\n\n# Set date/time based on date/time string\n# https://help.gnome.org/users/gthumb/stable/gthumb-date-formats.html.en\"\nts.from_iso(\"2022-04-22\", \"%Y-%m-%d\")\nprint(\"Timestamp:\", ts.timestamp())\n```\n\n# Get Unix Timestamp\n```python\nprint(\"Timestamp:\", ts.timestamp())\n```\n\n# Get current Unix Timestamp\n```python\nprint(\"Current Timestamp:\", ts.now())\n```\n\n# Add or subtract years\n```python\nts = Sometime(seconds)\nts.year(years=-25)\nts.year(years=100)\nprint(\"Year:\", ts.year())\nprint(\"Year:\", ts[\"%Y\"])\n```\n\n# Get name of the month\n```python\nts = Sometime(seconds)\nts.name_of_month()\nprint(\"Date of the Month:\", ts.name_of_month())\n```\n\n# Add or subtract months\n```python\nts = Sometime(seconds)\nts.month(months=-1)\nts.month(months=12)\nprint(\"Month:\", ts.month())\n```\n\n# Add or subtract days\n```python\nts = Sometime(seconds)\nts.day(days=-7)\nts.day(days=14)\nprint(\"Day:\", ts.day())\n```\n\n# Add or subtract hours\n```python\nts = Sometime(seconds)\nts.hour(hours=-8)\nts.hour(hours=24)\nhour = ts.hour()\nprint(\"Hour:\", ts.hour())\n```\n\n# Add or subtract minutes\n```python\nts = Sometime(seconds)\nts.minute(minutes=-5)\nts.minute(minutes=30)\nminute = ts.minute()\nprint(\"Minute:\", ts.minute())\n```\n\n# Add or subtract seconds\n```python\nts = Sometime(seconds)\nts.second(seconds=-1)\nts.second(seconds=30)\nsecond = ts.second()\nprint(\"Second:\", ts.second())\n```\n\n# Get if AM/PM\n```python\nts = Sometime(seconds)\nts.period()\nprint(\"Period:\", ts.period())\n```\n\n# Get the Day of the Week\n```python\nts = Sometime(seconds)\nprint(\"Day of the Week:\", ts.day_of_week())\n```\n\n# Add or subtract to date/time\n```python\nts = Sometime(seconds)\nprint(\"Timestamp:\", ts.timestamp())\nts.add(years=1, months=2, days=3, hours=4, minutes=5, seconds=6)\nprint(\"Timestamp:\", ts.timestamp())\n```\n\n# Format date/time into string representation\n```python\nts = Sometime(seconds)\nprint(\"Timestamp:\", ts.custom(\"%Y-%m-%d %H:%M:%S %p\"))\n```\n\n# Get yesterday's on custom formatting\n```python\nts = Sometime(seconds)\nprint(\"Yesterday:\", ts.yesterday(\"%Y-%m-%d %H:%M:%S %p\"))\n```\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "Get timestamp, formatted date, and perform date/time operations.",
    "version": "1.2.2",
    "split_keywords": [
        "date",
        "time",
        "timestamp",
        "utc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76eeb0c9cefe512190caecd99aab9296cb337670b604ea670f8bbeb21896bd98",
                "md5": "6b8a5f4fc467ca3b676ec8c21906c53b",
                "sha256": "f6a19431b62df6c7320fe01589571a96e86c95f9073e508c17d0bf759b9797e6"
            },
            "downloads": -1,
            "filename": "sometime-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6b8a5f4fc467ca3b676ec8c21906c53b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 4061,
            "upload_time": "2023-01-23T17:59:11",
            "upload_time_iso_8601": "2023-01-23T17:59:11.202273Z",
            "url": "https://files.pythonhosted.org/packages/76/ee/b0c9cefe512190caecd99aab9296cb337670b604ea670f8bbeb21896bd98/sometime-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "933c49f636b7856cf2d90c429e5d838f64feaa609e4cf4a9f5b8edf71674ddbc",
                "md5": "657efc8b3067f8ed305cc11ccd80de82",
                "sha256": "52e3869ca3aa31e1566e65058992bd8cca66fd3cb416f052b6761acea6b0fc15"
            },
            "downloads": -1,
            "filename": "sometime-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "657efc8b3067f8ed305cc11ccd80de82",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 3444,
            "upload_time": "2023-01-23T17:59:12",
            "upload_time_iso_8601": "2023-01-23T17:59:12.743909Z",
            "url": "https://files.pythonhosted.org/packages/93/3c/49f636b7856cf2d90c429e5d838f64feaa609e4cf4a9f5b8edf71674ddbc/sometime-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-23 17:59:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "sometime"
}
        
Elapsed time: 0.03877s