duration-humanizer 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manish Maheshwari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software...
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: duration-humanizer
3
+ Version: 0.2.0
4
+ Summary: Convert seconds into human readable format
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ License-File: LICENSE
8
+ Dynamic: license-file
@@ -0,0 +1,16 @@
1
+ # Duration Humanizer
2
+
3
+ A simple Python package that converts seconds into a human-readable duration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install duration-humanizer
9
+
10
+
11
+ Usage
12
+ from duration_humanizer import humanize
13
+
14
+ print(humanize(3661))
15
+
16
+ Output : 1 hour 1 minute 1 second
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "duration-humanizer"
7
+ version = "0.2.0"
8
+ description = "Convert seconds into human readable format"
9
+ requires-python = ">=3.9"
10
+ license = {text = "MIT"}
11
+
12
+ [tool.setuptools.packages.find]
13
+ where = ["src"]
14
+
15
+ [tool.setuptools.package-dir]
16
+ "" = "src"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .formatter import humanize
2
+
3
+ __version__ = "0.2.0"
@@ -0,0 +1,22 @@
1
+ def humanize(seconds):
2
+ if seconds == 0:
3
+ return "0 second"
4
+ hours = seconds // 3600
5
+ minutes = (seconds % 3600) // 60
6
+ remaining_seconds = seconds % 60
7
+
8
+ parts = []
9
+
10
+ if hours:
11
+ unit = "hour" if hours == 1 else "hours"
12
+ parts.append(f"{hours} {unit}")
13
+
14
+ if minutes:
15
+ unit = "minute" if minutes == 1 else "minutes"
16
+ parts.append(f"{minutes} {unit}")
17
+
18
+ if remaining_seconds:
19
+ unit = "second" if remaining_seconds == 1 else "seconds"
20
+ parts.append(f"{remaining_seconds} {unit}")
21
+
22
+ return " ".join(parts)
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: duration-humanizer
3
+ Version: 0.2.0
4
+ Summary: Convert seconds into human readable format
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ License-File: LICENSE
8
+ Dynamic: license-file
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/duration_humanizer/__init__.py
5
+ src/duration_humanizer/formatter.py
6
+ src/duration_humanizer.egg-info/PKG-INFO
7
+ src/duration_humanizer.egg-info/SOURCES.txt
8
+ src/duration_humanizer.egg-info/dependency_links.txt
9
+ src/duration_humanizer.egg-info/top_level.txt
10
+ tests/test_formatter.py
@@ -0,0 +1 @@
1
+ duration_humanizer
@@ -0,0 +1,28 @@
1
+ from duration_humanizer import humanize
2
+
3
+ def test_duration():
4
+ assert humanize(3661) == "1 hour 1 minute 1 second"
5
+
6
+ def test_minutes():
7
+ assert humanize(60) == "1 minute"
8
+
9
+ def test_hours():
10
+ assert humanize(3600) == "1 hour"
11
+
12
+ def test_seconds():
13
+ assert humanize(30) == "30 seconds"
14
+
15
+ def test_zero():
16
+ assert humanize(0) == "0 second"
17
+
18
+ def test_plural_hours():
19
+ assert humanize(7200) == "2 hours"
20
+
21
+ def test_plural_hours():
22
+ assert humanize(7200) == "2 hours"
23
+
24
+ def test_plural_minutes():
25
+ assert humanize(120) == "2 minutes"
26
+
27
+ def test_plural_seconds():
28
+ assert humanize(30) == "30 seconds"