日期,时间和日历操作有哪些语言真的很好? [英] What languages do date, time, and calendar operations really well?

查看:113
本文介绍了日期,时间和日历操作有哪些语言真的很好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是太多问题了,但是有什么语言能够表达时间和日期操作的非常好的工作吗?我会马上给予这个真的很难写一个真正伟大的时间库。那就是说有没有一种广泛的语言呢?基本上,我想要像现代正规表达式库做他们的工作那样全面地处理时间和日期的东西。我在Python和Java中看到的一切都省略了一个或多个相当重要的部分,或者使得太多的事情变得困难。

This is probably too much to ask, but is there any language that does a really terrific job of representing time and date operations? I'll grant straight away that it's really hard to write a truly great time library. That said, are there any widespread languages that have one? Basically, I want something that handles time and date as comprehensively as modern regular expression libraries do their jobs. Everything I've seen so far in Python and Java omits one or more pretty important pieces, or makes too many things hard.

至少这应该是直观的:

At least this should be intuitive to do:


  • 查找两个给定日期之间的天数,两个给定的分钟之间的分钟数等。

  • 从时间戳添加和减去间隔

  • 允许在时区之间进行简单转换,按区域自动计算的夏令时更改(由于有一个准确的区域设置支持数据库可用)

  • 获取给定时间戳记的时间段,给定周期粒度(这个日期在哪个日历日?)

  • 支持非常一般字符串到目前为止的转化(给定一个模式)

  • find the number of days between two given dates, number of minutes between two given minute periods, etc.
  • add and subtract intervals from timestamps
  • allow simple conversion between timezones, with Daylight Saving Time changes by region automatically accounted for (given that there's an accurate supporting database of regional settings available)
  • get the period that a given timestamp falls into, given period granularity ("what calendar day is this date in?")
  • support very general string-to-date conversions (given a pattern)

此外,如果有一个Java风格的Calendar / GregorianCalendar设置,如果我需要滚自己的他,班级应该适应子类酿造,巴比伦,托尔金或火星日程。 (例如,Java日历使这一点毫无意义。)

Further, if there's a Java-style Calendar/GregorianCalendar setup, the general Calendar class should be accommodating toward subclasses if I need to roll my own Hebrew, Babylonian, Tolkien, or MartianCalendar. (Java Calendars make this pointlessly hard, for example.)

我在这里完全与语言无关。如果事情阻碍了计算模糊的东西,比如2002年和下一个情人节之间有多少分钟?,那么这样做会很好吗?

I am completely language-agnostic here. It's fine if the thing chokes on computing ambiguous stuff like "how many minutes are there between 2002 and next Valentine's Day?"

推荐答案

如何 .NET的DateTime ? (您可以在框架内选择您的语言)

How about .NET's DateTime? (You can pick your language within the framework)

这篇关于日期,时间和日历操作有哪些语言真的很好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆