iso8601

Output Ruby duration in iso8601

跟風遠走 提交于 2019-12-13 15:24:47
问题 I'm looking to output duration in iso8601 format in ruby on rails for schema.org. I already know how to output the timestamp in iso8601. e.g. video.created_at.iso8601 What I'm looking to do now is output something in the format of: <meta itemprop="duration" content="PT1M33S" /> That's the iso8601 duration format. You can read about the spec at http://en.wikipedia.org/wiki/ISO_8601#Durations Currently I'm hacking in a strftime, but that's not ideal... Time.at(@video.duration).strftime('PT%MM:

javascript ISO8601 3.5.2 Time Of Day (24-hour) datatype disconnected from calendar

自古美人都是妖i 提交于 2019-12-13 04:24:58
问题 ISO 8601 3.5.2 distinguishes between date-time combined values and time-only values. Time-only values model the 24-hour clock of an indeterminate day not on the calendar. For Time-Only values, 24:00 is a valid value, to distinguish the end-of-the-day from the start-of-the-day (00:00). Until explicitly attached to a day on the calendar, Time-Only values are simply a point on the segment of finite time that runs from 00:00 to 24:00. What is the current ECMA standard with respect to Time-only

Javascript - reformat date string to ISO8601

江枫思渺然 提交于 2019-12-13 02:13:36
问题 I have a string like this: 21.03.2016 23:59 And I need this string converted into a ISO-8601 date-time string: YYYY-MM-DDTHH:mm:ss+00:00 Is there a simple way to convert this date? I try it whit moment.js but i can't find a function to parse an existing date. 回答1: You can also do this without using moment.js. Look code as following: (new Date("03.21.2016 23:59")).toISOString() just you need to change your string 21.03.2016 23:59 (dd-mm-yyyy) to 03.21.2016 23:59 (mm-dd-yyyy) . You can easily

Timestamp to ISO 8601 in Lua

ⅰ亾dé卋堺 提交于 2019-12-12 10:32:01
问题 How would you convert a timestamp to an ISO 8601 format (such as 2009-01-28T21:49:59.000Z ) in Lua? I'm specifically trying to do it by using the HttpLuaModule in Nginx. 回答1: Try os.date("!%Y-%m-%dT%TZ") or os.date("!%Y-%m-%dT%TZ",t) if t has the date in seconds since the epoch. 回答2: Or you can use: local now_date_time = os.date("!%Y%m%dT%H%M%S") --> For date_time: 20191015T042028Z local now_date = os.date("!%Y%m%d") --> For only date: 20191015 来源: https://stackoverflow.com/questions/20131891

How to add types information to JSON on serialization?

时光怂恿深爱的人放手 提交于 2019-12-12 03:43:23
问题 Angular requires Date objects in many places whereas JSON contains string representation of the date. I want to add an array of properties which contain date values: class Foo { public int IntProp {get;set;} public DateTime? Prop1 {get;set;} public DateTime Prop2 {get;set;} public Bar Bar {set;set;} } class Bar { public DateTime Prop {get;set;} public IEnumerable<DateTime?> Dates {get;set;} } Foo should then be serialized like this: { "IntProp": 1, "Prop1": "...", "Prop2": "...", "Bar": {

MySQL ISO 8601 Date with Timezone offset instead of Z value

拜拜、爱过 提交于 2019-12-11 12:07:48
问题 I need to SELECT a ISO 8601 Date. DATE_FORMAT(date, '%Y-%m-%dT%TZ') This produces something like 2013-11-13T15:47:530Z But I need it with the offset instead of Z value: 2013-11-13T15:47:53+02:00 How can I do this with plain MySQL ? 回答1: You need to store the timezone as an extra column in DB. I do not know any DB that stores datetime with timezone/offset. Or store the date as string in ISO 8601 format with offset.. Edit: I stand somewhat corrected, with some newer databases it is possible!

Map iso8601 date time string to Julian Day using javascript

不想你离开。 提交于 2019-12-11 07:16:18
问题 Does anyone have a compact / elegant map from an ISO-8601 date time string of the following form: 2013-12-28T20:30:00-0700 To a Julian day. I'm hoping to find a solution that avoids an external library and has minimal regex and string manipulation. 回答1: Here’s one way to do it. You can convert an ISO string—with a time zone offset too—to a JavaScript Date object in modern JavaScript (ES5). This works in Node.js, Chrome and Firefox. It is not yet supported in Safari or IE. If you need it to

Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

纵饮孤独 提交于 2019-12-11 05:49:35
问题 This is directly related to my question POSIX date from dates in weekly time format. However, in this question I'd like to specifically ask for how to map ISO 8601 week numbers to month of the year numbers. To me, it seems it is not possible and/or involves some non-intuitive hacks (and even these don't really work reliably) and IMO should thus be considered as something that needs to be fixed in base R . Please correct me if I'm wrong, though EDIT: seems like it the issue is closely related

Convert ISO 8601 Date to a Standard String Format

99封情书 提交于 2019-12-11 03:11:26
问题 I am trying to convert a valid ISO 8601 string to a consistent format so that sort and search using simple lexicographical order is possible. My application could receive a date/time in any of the following formats, for example: 2015-02-05T02:05:17.000+00:00 2015-02-05T02:05:17+00:00 2015-02-05T02:05:17Z These all represent the same date/time and I would like to convert them all to a canonical form for storage, say: 2015-02-05T02:05:17.000Z My first thought was to just parse them using a

Conversion from ISO8601 Duration to Time and from Time to ISO8601 Duration

江枫思渺然 提交于 2019-12-11 02:54:24
问题 I have duration value in ISO8601 format and I convert it to the value of time as an integer number of seconds as below: Duration value in ISO8601 format = "P1Y". duration = ISO8601::Duration.new(params[:duration]).to_seconds # duration would have value in float, but I need it in int, so converting it to int. time_in_seconds = (Time.now - duration).to_i I store the value in 'time_in_seconds'. So when I retrieve the value would be in int, which I want to convert back to ISO8601 duration format