[Repo Assist] feat: add calendar module bindings and tests#82
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[Repo Assist] feat: add calendar module bindings and tests#82github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Adds Fable.Beam.Calendar with bindings for the Erlang calendar module (date, time, datetime, Gregorian conversions): - ImportAll bindings: date, time, local_time, universal_time, day_of_the_week, is_leap_year, last_day_of_the_month, date_to_gregorian_days, gregorian_days_to_date, gregorian_seconds_to_datetime - Emit bindings: datetimeToGregorianSeconds, timeToSeconds, secondsToTime, localTimeToUniversalTime, universalTimeToLocalTime - Type aliases: Date, Time, DateTime for clarity - 24 tests covering deterministic functions (leap year, day-of-week, Gregorian day/second roundtrips, time/seconds conversions) plus sanity checks on live-clock functions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated contribution from Repo Assist, an AI assistant.
What
Adds
Fable.Beam.Calendar— F# bindings for Erlang'scalendarmodule (stdlib), covering date/time introspection and Gregorian calendar arithmetic.Changes
src/otp/Calendar.fs(new)Type aliases (for readability):
type Date = int * int * int— (Year, Month, Day)type Time = int * int * int— (Hour, Min, Sec)type DateTime = Date * Time— ((Year,Month,Day),(Hour,Min,Sec))[<ImportAll>]bindings (multi-arg variants where available):calendar.date()calendar.time()calendar.local_time()calendar.universal_time()calendar.day_of_the_week(year, month, day)calendar.is_leap_year(year)calendar.last_day_of_the_month(year, month)calendar.date_to_gregorian_days(year, month, day)calendar.gregorian_days_to_date(days)calendar.gregorian_seconds_to_datetime(seconds)[<Emit>]bindings (functions that take single tuple args on the Erlang side):datetimeToGregorianSeconds(datetime)int64)timeToSeconds(time)secondsToTime(seconds)localTimeToUniversalTime(datetime)universalTimeToLocalTime(datetime)test/TestCalendar.fs(new) — 24 testsis_leap_year: 2000 ✓, 2024 ✓, 1900 ✗ (century rule), 2023 ✗last_day_of_the_month: Jan=31, Feb leap=29, Feb non-leap=28, Apr=30day_of_the_week: Mon/Fri/Sun for known 2024 datesdate_to_gregorian_days/gregorian_days_to_date: roundtrip + known value (2000-01-01 = day 730485)timeToSeconds/secondsToTime: midnight, noon, 01:30:30 roundtripsdatetimeToGregorianSeconds/gregorian_seconds_to_datetime: roundtrip + known value (2000-01-01 00:00:00 = 63113904000)date,time,local_time,universal_time: sanity-range checks on live valuesOther
src/Fable.Beam.fsproj: addedCalendar.fsafterRe.fstest/Fable.Beam.Test.fsproj: addedTestCalendar.fsafterTestRe.fsREADME.md: addedFable.Beam.CalendarandFable.Beam.Reto module tableNotes
datetimeToGregorianSecondsreturnsint64because Gregorian seconds for modern dates exceed 231 (e.g. 2000-01-01 = 63,113,904,000).localTimeToUniversalTime/universalTimeToLocalTimeresults are timezone-dependent; no test asserts specific UTC offset.dotnet build test/. Full BEAM validation by CI.