Add PlanetaryTime.time and .date convenience properties
This commit is contained in:
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.2.0] - 2026-04-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `PlanetaryTime.time` property — current time of sol as formatted string `HH:MM:SS`
|
||||||
|
- `PlanetaryTime.date` property — current date as formatted string `Year X, Sol Y`
|
||||||
|
|
||||||
## [1.1.0] - 2026-04-16
|
## [1.1.0] - 2026-04-16
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
20
PROJECT.md
20
PROJECT.md
@@ -76,14 +76,14 @@ Moon and dwarf planets (Pluto, Ceres, Eris) may be added later.
|
|||||||
- Project scaffolded (Poetry, src layout, tests directory)
|
- Project scaffolded (Poetry, src layout, tests directory)
|
||||||
- No implementation yet
|
- No implementation yet
|
||||||
|
|
||||||
## TODO
|
## Pending work
|
||||||
|
|
||||||
- Define `Body` enum with rotation periods
|
- TODO: Define `Body` enum with rotation periods
|
||||||
- Define `Epoch` enum and epoch registry
|
- TODO: Define `Epoch` enum and epoch registry
|
||||||
- Implement core `PlanetaryTime` class
|
- TODO: Implement core `PlanetaryTime` class
|
||||||
- Implement conversion from Earth `datetime`
|
- TODO: Implement conversion from Earth `datetime`
|
||||||
- Implement `__str__` / `__repr__`
|
- TODO: Implement `__str__` / `__repr__`
|
||||||
- Write tests for conversion accuracy
|
- TODO: Write tests for conversion accuracy
|
||||||
- Write tests for epoch switching
|
- TODO: Write tests for epoch switching
|
||||||
- Populate README with usage examples
|
- TODO: Populate README with usage examples
|
||||||
- Implement `scripts/refresh_data.py` — fetches rotation periods, orbital periods and discovery dates from Wikidata SPARQL endpoint and regenerates hardcoded data in `body.py`, `moon.py` and `epoch.py`; script is not part of the distributed package
|
- TODO: Implement `scripts/refresh_data.py` — fetches rotation periods, orbital periods and discovery dates from Wikidata SPARQL endpoint and regenerates hardcoded data in `body.py`, `moon.py` and `epoch.py`; script is not part of the distributed package
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "planetarytime"
|
name = "planetarytime"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
description = "Python library for representing and working with time on other bodies in the Solar System"
|
description = "Python library for representing and working with time on other bodies in the Solar System"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "Jan Doubravský", email = "jan.doubravsky@gmail.com"}
|
{name = "Jan Doubravský", email = "jan.doubravsky@gmail.com"}
|
||||||
|
|||||||
@@ -139,6 +139,16 @@ class PlanetaryTime:
|
|||||||
"""Second within the current minute (0-indexed)."""
|
"""Second within the current minute (0-indexed)."""
|
||||||
return self._second
|
return self._second
|
||||||
|
|
||||||
|
@property
|
||||||
|
def time(self) -> str:
|
||||||
|
"""Current time of sol as 'HH:MM:SS'."""
|
||||||
|
return f"{self._hour:02d}:{self._minute:02d}:{self._second:02d}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def date(self) -> str:
|
||||||
|
"""Current date as 'Year X, Sol Y'."""
|
||||||
|
return f"Year {self._year}, Sol {self._sol}"
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# String representation
|
# String representation
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user