是否有定制 Joda-Time 年表的优质资源?

发布于 2024-12-03 01:57:06 字数 309 浏览 1 评论 0原文

我正在开发一款 RPG 风格的游戏,我想为该游戏开发一个具有独特月份、工作日、月份长度和日期长度的自定义日历。我最初计划覆盖 JDK 日历并尝试这样做;然而,我遇到了 Joda-Time,它对于这个目的来说似乎更有前途和更强大。但是,我无法弄清楚如何创建自己的年表,并且想知道是否有好的资源(我似乎找不到)来解释如何创建年表。

我尝试过设计一个超载的 AssembledChronology,但似乎无法让它满足我的需求。我想要的是一个 9 个月的日历,每月 40 天,每周 10 天。除此之外,每年还有最后一个“无月”的第十个月,仅持续 5 天。

任何帮助/建议表示赞赏。

I'm working on an RPG style game and I want to develop a custom Calendar for the game with unique months, week-days, month lengths, and day lengths. I was planning originally to override the JDK Calendar and attempt to do it that way; however, I ran across Joda-Time and it seemed more promising and powerful for this purpose. However, I'm having trouble figuring out to create my own Chronology and was wondering if there were good resources (that I can't seem to find) that explain how to create a Chronology.

I've tried come up with an overloaded AssembledChronology but can't seem to get it to fit my needs. And idea of what I want is a 9 month Calendar with 40 days a month, 10 days a week. In addition to that, there is a final "monthless" 10th month per year that only lasts 5 days.

Any help/advice is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开浅夏 2024-12-10 01:57:06

我的建议:不要尝试用 Joda Time 来做到这一点。

也许是可能的 - 尽管“无月”的月份听起来有点奇怪 - 并且 Joda Time 无疑是建立在灵活性之上的......但是让你的头脑了解 AssembledChronology、DelegateDateTimeFieldDecolatedDateTimeField 等可能会让您感到困惑。哦,然后您需要时区的可能性。

老实说,您的日历听起来非常简单 - 足够简单,从头开始实现一个简单的 API 可能比尝试详细了解 Joda Time 的实现更简单。

不要误会我的意思:我喜欢 Joda Time,因为我将它用于正常的业务应用程序。它比DateCalendar 好得多,一旦你开始使用它就没有回头路了 - 但它很复杂。

(就上下文而言,我将 Joda Time 移植到 .NET,或者至少是它的“引擎”部分。它有相当详细的文档记录,但到处都有大量的继承层次结构,这不利于“只是“创建一个新的日历系统。对于已经了解 Joda Time 细节的人来说,最终可能不需要很多代码,但它足够棘手,否则我会尽量避免它。)

当然,这真的取决于取决于您需要多丰富的 API。如果您确实想要 Joda Time 的所有功能,那么安装您的日历系统确实比您自己重新实现所有 API 更简单。另一方面,如果您主要只是想表达“这是我的自定义日历中的一个日期”,那么有更简单的方法可以实现它。就游戏中的日期/时间算术而言,您真正需要什么?

My advice: don't try to do it with Joda Time.

It may be possible - although a "monthless" month sounds a little odd - and Joda Time is certainly built on flexibility... but getting your head round all of the business of AssembledChronology, DelegatedDateTimeField, DecoratedDateTimeField etc is likely to do your head in. Oh, and then you need the possibility of time zones.

Your calendar sounds quite simple to be honest - sufficiently simple that implementing a straightforward API from scratch may well be simpler than trying to understand the implementation of Joda Time in detail.

Don't get me wrong: I love Joda Time in terms of using it for normal business applications. It's so much better than Date and Calendar, there's really no turning back once you've started using it - but it is complicated.

(Just in terms of context, I'm porting Joda Time to .NET, or at least the "engine" part of it. It's fairly well documented but there are large inheritance hierarchies all over the place, and it's just not conducive to "just" creating a new calendar system. It may well not take a lot of code in the end for someone who already knows the details of Joda Time, but it's sufficiently tricky otherwise that I'd just try to avoid it.)

Of course, it really depends on how rich an API you need. If you really want all the power of Joda Time, then fitting your calendar system in would indeed be simpler than re-implementing all of the API yourself. On the other hand, if you're mostly just after a way of saying, "Here's a date in my custom calendar" then there are simpler ways of achieving it. What do you really need in terms of date/time arithmetic in your game?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文