[Proposal] Calendar callback months_in_year/1

29 views
Skip to first unread message

Kip

unread,
Mar 3, 2018, 8:11:03 PM3/3/18
to elixir-lang-core
I'm back working on calendar-related functions.  I'd like to propose an addition to the Calendar behaviour:

@callback months_in_year(year) :: month

Which returns the number of months in a year.  An example use I'm currently work on is subscriptions.  I bill monthly and therefore want to calculate "next month".  I can increment month in {year, month, day} but then I need to know what the modulo is.

Not all calendars have 12 months.  The Hebrew calendar, for example, has 13 months in a leap year.  The balinese saka calendar has a similar intercalary month added from time-to-time.

I accepted I will craft a PR for this for Calendar, Calendar.ISO and tests.

--Kip

José Valim

unread,
Mar 4, 2018, 6:11:59 AM3/4/18
to elixir-l...@googlegroups.com
Yes, a PR will be appreciated. Thank you!

If you can revisit any place we rely on the 12 months assumption, if any, that would be very welcome too.



José Valim
Founder and 
Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/812c799c-cf39-45cc-a202-6953bea3a496%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages