English 中文(简体)
是否有一部关于ISO 8601的全面图书馆/单元。
原标题:Is there a comprehensive library/module for ISO 8601 in ruby?

ISO 8601在废墟中的标准? 我指的是像你能够确定和获得细节的一类,例如,年、月、日、日等——每周、周、小时、分钟——是_耐久? 因此,也可以由谁来确定并出口到扼杀物?

问题回答
require  time 

time = Time.iso8601 Time.now.iso8601 # iso8601 <--> string
time.year    # => Year of the date 
time.month   # => Month of the date (1 to 12)
time.day     # => Day of the date (1 to 31 )
time.wday    # => 0: Day of week: 0 is Sunday
time.yday    # => 365: Day of year
time.hour    # => 23: 24-hour clock
time.min     # => 59
time.sec     # => 59
time.usec    # => 999999: microseconds
time.zone    # => "UTC": timezone name

查阅time。 它有许多缺陷。

不幸的是,Ruby s公司的固定时间职能似乎并不通过(例如与网络相比)来很好地考虑,因此,为了其他功能,你将需要使用一些地段。

好事是,使用这些宝石同它一样,使鲁比执行成为一环。

Most useful probably is Time Calculations from ActiveSupport (Rails 3).
You don t need to require the rails but only this small library: gem install activesupport.

然后

require  active_support/all 
Time.now.advance(:hours => 1) - Time.now # ~ 3600
1.hour.from_now - Time.now # ~ 3600 - same as above
Time.now.at_beginning_of_day # ~ 2010-11-24 00:00:00 +1100
# also at_beginning_of_xxx: xx in [day, month, quarter, year, week]
# same applies to at_end_of_xxx

你确实可以做很多事情,我认为你会发现什么适合你们的需要。

因此,我不向各位提供这方面的抽象例子,而是鼓励你从中试验<代码>irb,要求active_support

保留 实时计算





相关问题
Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse ...

How does a .NET process get the culture information?

I have a Windows service running (C#, .NET 2.0) on Windows Server 2003 R2. In one server the System.Threading.Thread.CurrentThread.CurrentCulture is {en-AU} and in the other {en-US}. This has caused a ...

Best way to get maximum Date value in java?

I m writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special ...

Date format in SQL Server

Short Question: What s the best date format to use in SQL Server? Long Explanation: We re converting our database from mysql to SQL Server. In mysql we always used int(11) to avoid the daylight ...

Converting asp.net/sql web app to be ime zone savy

Our current app stores all dates via the server s datetime. I m thinking we need to update all datetime values in the database over to UTC time. Now for displaying these dates back to the user, I ...

Check if string is of SortableDateTimePattern format

Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression? I ve got a form where users can input a copyright date (as a ...

DateTime in PropertyGrid in .Net

I m currently working on some DateTime properties in a PropertyGrid in c#.Net. Im using the default drop-down datetime picker. My question: Is there any way to show the full date with the time? By ...

热门标签