Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom calendars #17

Open
bmarwell opened this issue Oct 23, 2019 · 11 comments
Open

Custom calendars #17

bmarwell opened this issue Oct 23, 2019 · 11 comments

Comments

@bmarwell
Copy link

Hi,

Is there are way to add custom calendars? I know in java this is possible.

If not, well, this is a feature request. 😉

@BenMorel
Copy link
Member

Hi, no there isn't at the moment. Could you please describe your use case?

@bmarwell
Copy link
Author

Hi @BenMorel, sure.

Use case description

Please take a look at this project: https://github.com/fisharebest/webtrees/

Webtrees is a online Genealogy software. That means, you input the date of an individuals birth, death, some-other-event in the date which was mentioned in the SOURCES. That said, you'd put in George Washingtons Birthday in the Julian Calendar, but when he died the gregorian calendar was in use.

user story

As a user, I'd expect to see the Proleptic calendar date of Washingtons birth (if I wanted to), and the age should also be calculated in the gregorian/proleptic style.

technical background

  • As a Java user, I know that the JSR310 is very extensible and this is omited (for now) from this project.
  • webtrees supports the following calendars at the moment: jewish, arabic, french, julian, gregorian.
  • webtrees does not support Japanese ERA, which is included in JSR310.
  • I think adding more calendars to webtrees will be easier with a JSR310-based implementation.
  • I think calculation based on JSR310 are less error-prone.
  • What about timezone updates and DST handling? I am not sure webtrees can handle this correctly right now, but I honestly haven't checked.

We have a webtrees slack. A new version 2.0.0 (based on laravel) is on its way, but wouldn't include brick/date-time. I wanted to investigate if this library adds some benefits over the existing implementation.

As you seem to know PHP and Java (including JSR310), I think you could explain the benefits of this implementation in the slack. But maybe I am mistaken, and JSR310 does not support the calendars I mentioned, because it is not as extensible as I remembered.

Regards,
Ben

@bmarwell
Copy link
Author

bmarwell commented Oct 24, 2019

Other things to consider:

None of the other libraries can support this: icecave/chrono and briannesbitt/Carbon for example, but also cakePHP's port are unable to have a calendar implemented. This library is the only one that could have a calendar interface extracted, which I hope is similar to JSR310's interface.

@BenMorel
Copy link
Member

BenMorel commented Jan 8, 2020

Hi @bmhm,

Thank you for your use case description.

I'm open to adding support for custom calendars; however, I'm not familiar with other calendars at all, so unless I'm extensively briefed on the matter, and get enough time to work on it, I'm currently unable to help.

Would you be interested in opening a PR to add support for these calendars?

@bmarwell
Copy link
Author

bmarwell commented Jan 8, 2020

Phew. I looked into your code and I realized two things.

  • My php skills are far from those you have
  • Your class looks quite different than the ones from the JDK

So I'm probably not able to help. ☹️

@BenMorel
Copy link
Member

BenMorel commented Jan 8, 2020

If you give me some examples of how a different calendar affects the behaviour of existing classes such as LocalDate etc., I might be able to get a better understanding of the situation!

@bmarwell
Copy link
Author

bmarwell commented Jan 8, 2020

@BenMorel
Copy link
Member

BenMorel commented Jan 8, 2020

If custom calendars just meant a different date for today (with the same year-month-day concept), this would probably be quite easy to implement.

But from what I can see by quickly browsing your links, calendars like the Japanese one do not seem to use the same concept of year-month-day, you'd need an additional era field that does not have any meaning in our calendar, so it's a totally different beast and I'm not sure whether this is in the scope of this project (at least at the moment).

@bmarwell
Copy link
Author

bmarwell commented Jan 8, 2020

Yes that's what I meant I'm the first place. I do not know of any library which could provide this. But yours is based on jsr310 and would be somewhat easy to extend to the same functionality.

Yes, some calendar systems have a different number of months or not the concept of months at all.

@BenMorel
Copy link
Member

BenMorel commented Jan 8, 2020

Although very similar, the project is not a direct port of JSR-310, it misses some concepts such as these calendars, and integrates others that, AFAIK, are missing in java.time, such as LocalDateRange, and timecop-inspired clocks.

I'm not against integrating these calendars at some point in the future, but I won't be able to investigate this further at the moment. I'll keep this issue open, though, if someone wants to jump in and work on a PR!

@bmarwell
Copy link
Author

bmarwell commented Jan 9, 2020

Thanks. I'll try to find someone to work with on this. Maybe we could even start a branch together at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants