iso8601

Parse ISO 8601 durations

て烟熏妆下的殇ゞ 提交于 2019-11-28 13:29:25
In ISO 8601, durations are given in the format P[n]Y[n]M[n]DT[n]H[n]M[n]S . Examples: 20 seconds: PT20.0S One year, 2 month, 3 days, 4 hours, 5 minutes, 6 seconds: P1Y2M3DT4H5M6S Question: Given a string that contains a duration in iso 8601 format. I want to obtain the overall number of seconds of that duration. What is the recommended way in standard C++11 to achieve this? Remarks: E.g., there is ptime from_iso_string(std::string) in boost DateTime which does not fit here. Is there a similar way without doing a regex by hand? Use the standard regex library, the regex you want is something

Sort ISO 8601 dates forward or backwards

怎甘沉沦 提交于 2019-11-28 11:01:43
I have an array of dates in ISO8601 format and need to sort them. Does anyone have a suggestion for an algorithm that would work? I don't think they will sort as strings unless I'm much mistaken, so I assume they have to be broken down into their component parts? Can someone post an algorithm, preferably language agnostic, but VB or C# example would work as long as it just uses strings and integers and no functions that are built-in to the language. Thanks! It depends on whether or not you're mixing formats. Within any specific format, like yyyy-mm-dd or yyyy-Www-d , ISO 8601 is built to sort

How to bind ISO8601 TSQL DATETIME parameter with PDO?

一笑奈何 提交于 2019-11-28 08:08:38
问题 It seems that PDO has a problem with ISO 8601 formatted timestamps. I'm connecting from 64-bit Ubuntu 16.04 running PHP 7.0.8 using the Microsoft® ODBC Driver 13 (Preview) for SQL Server® Here's my simple table: CREATE TABLE dtest ( "stamp" DATETIME ); Works: $pdoDB = new PDO('odbc:Driver=ODBC Driver 13 for SQL Server; Server='.DATABASE_SERVER.'; Database='.DATABASE_NAME, DATABASE_USERNAME, DATABASE_PASSWORD ); $pdoDB->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "INSERT

Parsing ISO 8601 with NSDateFormatter

混江龙づ霸主 提交于 2019-11-28 06:37:56
问题 I've read through the various posts on SO about this, but have still not solved the problem. Here's the string that I'm trying to parse into an NSDate object: 2012-04-08T12:00:00.00+02:00 I understand that the problem is the time zone format. Here's the date format string that I'm trying: yyyy-MM-dd'T'HH:mm:SSZZZZ Thanks for any help. 回答1: Three things: Use the -[NSDateFormatter getObjectValue:forString:range:error:] method to learn how much of the string was parsed and what error prevented

What mode for MySQL WEEK() complies with ISO 8601

夙愿已清 提交于 2019-11-28 05:14:59
What mode for MySQL's WEEK() function yields the ISO 8601 week of the year ? Argument 2 of WEEK() sets the mode according to this chart: +--------------------------------------------------------------------+ | Mode | First day of week | Range | Week 1 is the first week ... | |------+-------------------+-------+---------------------------------| | 0 | Sunday | 0-53 | with a Sunday in this year | |------+-------------------+-------+---------------------------------| | 1 | Monday | 0-53 | with more than 3 days this year | |------+-------------------+-------+---------------------------------| | 2

Python UTC datetime object's ISO format doesn't include Z (Zulu or Zero offset)

巧了我就是萌 提交于 2019-11-28 04:15:46
Why python 2.7 doesn't include Z character (Zulu or zero offset) at the end of UTC datetime object's isoformat string unlike JavaScript? >>> datetime.datetime.utcnow().isoformat() '2013-10-29T09:14:03.895210' Whereas in javascript >>> console.log(new Date().toISOString()); 2013-10-29T09:38:41.341Z stiv Python datetime objects don't have time zone info by default, and without it, Python actually violates the ISO 8601 specification ( if no time zone info is given, assumed to be local time ). You can use the pytz package to get some default time zones, or directly subclass tzinfo yourself: from

ISO8601 with milliseconds in json using Jackson

冷暖自知 提交于 2019-11-28 03:56:42
问题 import com.fasterxml.jackson.databind.util.ISO8601DateFormat; objectMapper.setDateFormat(new ISO8601DateFormat()); Nice but this ignores milliseconds, how can I get them in the dates without using the non-thread-safe SimpleDateFormatter ? https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/util/ISO8601DateFormat.java 回答1: ISO8601DateFormat.format calls ISO8601Utils.format(date) , which in turn calls format(date, false, TIMEZONE_Z) - the false

Parsing ISO 8601 string to DateTime in .NET? [duplicate]

不问归期 提交于 2019-11-28 01:18:06
This question already has an answer here: How to create a .NET DateTime from ISO 8601 format 7 answers I have a string, "2009-10-08 08:22:02Z", which is in ISO 8601 format. How do I use DateTime to parse this format? JDunkerley string txt= "2009-10-08 08:22:02Z"; DateTime output = DateTime.ParseExact(txt, "u", System.Globalization.CultureInfo.InvariantCulture); The DateTime class supports the standard format string of u for this format I think for the ISO format (with the T separator), use "s" instead of "u". Or use: string txt= "2009-10-08 08:22:02Z"; DateTime output = DateTime.ParseExact(txt

Convert String ISO-8601 date to oracle's timestamp datatype

拥有回忆 提交于 2019-11-28 00:53:11
I have a ISO-8601 date in VARCHAR2 type, how can i convert that String date to timestamp in oracle db? Date Example: "2014-09-12T11:53:06+00:00" Maybe is something like the following but i not sure what is the format. SELECT to_timestamp_tz ('2014-09-12T11:53:06+00:00', ????) FROM DUAL The date format model elements are listed in the documentation : SELECT to_timestamp_tz ('2014-09-12T11:53:06+00:00', 'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM') FROM DUAL TO_TIMESTAMP_TZ('2014-09-12T11:53:06+00:00','YYYY-MM-DD"T"HH24:MI:SSTZH:TZM ---------------------------------------------------------------------------

How do I convert an ISO 8601 string to a Delphi TDate?

吃可爱长大的小学妹 提交于 2019-11-27 22:49:30
I can convert a Delphi TDate to ISO 8601 format easily using this: DateTimeToString(result, 'yyyy-mm-dd', myDate); What's the idiomatic way to do the inverse conversion? StringToDateTime() doesn't seem to exist. Obviously I can do it the "hard" way by manually parsing the string and encoding the result, but that seems a poor choice. Jeroen Wiert Pluimers why re-invent the wheel? XML uses ISO 8601 for date and date-time storage. Delphi has had built-in support for that since Delphi 6 in the XSBuiltIns unit. This answer explains how for DateTime, this is for Date only using the TXSDate class: