CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-lunar-python

tessl install tessl/pypi-lunar-python@1.4.0

Comprehensive Chinese lunar calendar library with Solar calendar conversion and traditional Chinese calendar features.

Agent Success

Agent success rate when using this tile

79%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.9x

Baseline

Agent success rate without this tile

88%

task.mdevals/scenario-9/

Dual Calendar Conversion

Build a tiny bridge module that focuses solely on creating solar or lunar dates and converting between them, including Julian day inputs. The goal is to exercise accurate transformations, time preservation, and leap-month awareness without recreating calendar math.

Capabilities

Solar to lunar conversion

  • Converting the Gregorian date-time 2023-01-22 09:30:15 produces lunar year 2023, month 1, day 1 with the same time components and a non-leap month flag. @test

Leap month handling

  • Converting lunar year 2020, leap month 4, day 2 at 08:00:00 to a Gregorian date yields 2020-05-24 08:00:00; converting back to lunar preserves the leap-month marker and original lunar fields. @test

Julian day support

  • Initializing from Julian day 2459215.5 returns the Gregorian date 2021-01-01 00:00:00, and converting that instance back to Julian day reproduces 2459215.5. @test

Bidirectional round-trip

  • Converting 2017-09-30 23:59:59 from Gregorian to lunar and back returns the identical Gregorian date-time. @test

Implementation

@generates

API

class CalendarBridge:
    @staticmethod
    def from_solar(year: int, month: int, day: int,
                   hour: int = 0, minute: int = 0, second: int = 0) -> "CalendarBridge": ...

    @staticmethod
    def from_lunar(year: int, month: int, day: int,
                   hour: int = 0, minute: int = 0, second: int = 0,
                   leap_month: bool = False) -> "CalendarBridge": ...

    @staticmethod
    def from_julian_day(julian_day: float) -> "CalendarBridge": ...

    def to_solar_tuple(self) -> tuple: ...  # (year, month, day, hour, minute, second)
    def to_lunar_tuple(self) -> tuple: ...  # (year, month, day, hour, minute, second, leap_month)
    def to_julian_day(self) -> float: ...  # Julian day number for the stored instant

Dependencies { .dependencies }

lunar_python { .dependency }

Chinese solar and lunar calendar conversions with Julian day and leap-month support. @satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/lunar-python@1.4.x
tile.json