iso8601

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

余生长醉 提交于 2019-12-17 16:27:00
问题 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. 回答1: 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.

MySQL insert to DATETIME: is it safe to use ISO::8601 format?

我的未来我决定 提交于 2019-12-17 15:56:13
问题 In our project we use Zend Framework Model generator, which produces something like this to set the properties that are stored in DB (MySQL) as DATETIME fields: public function setObjectDatetime($data) { if (! $data instanceof Zend_Date) { ... some conversion code ... } $this->objectDatetime = $data->toString(Zend_Date::ISO_8601); } So the ISO::8601 formatted string ('2012-06-15T18:33:00+03:00' for example) is what actually is stored as a property. The problem arises when we try to save this

Converting timezone-aware datetime to local time in Python

落花浮王杯 提交于 2019-12-17 15:27:01
问题 How do you convert a timezone-aware datetime object to the equivalent non-timezone-aware datetime for the local timezone? My particular application uses Django (although, this is in reality a generic Python question): import iso8601 .... date_str="2010-10-30T17:21:12Z" .... d = iso8601.parse_date(date_str) foo = app.models.FooModel(the_date=d) foo.save() This causes Django to throw an error: raise ValueError("MySQL backend does not support timezone-aware datetimes.") What I need is: d =

Python - Convert string representation of date to ISO 8601

微笑、不失礼 提交于 2019-12-17 10:56:09
问题 In Python, how can I convert a string like this: Thu, 16 Dec 2010 12:14:05 +0000 to ISO 8601 format, while keeping the timezone? Please note that the orginal date is string, and the output should be string too, not datetime or something like that. I have no problem to use third parties libraries, though. 回答1: Using dateutil: import dateutil.parser as parser text = 'Thu, 16 Dec 2010 12:14:05 +0000' date = parser.parse(text) print(date.isoformat()) # 2010-12-16T12:14:05+00:00 回答2: Python

Annoying javascript timezone adjustment issue

寵の児 提交于 2019-12-17 09:51:55
问题 I have set up a JSON endpoint that returns the current time from server. For example: { "myservertime": "2011-10-02T23:00+02:00" } So this is the CET summer time right now. Now, I also have a jQuery code that parses that very well. $.sysTime = function(success) { $.ajax({ url: '/jsontimepath/', dataType: 'json', async: false, success: function(json){ sysDateTime = new Date(Date.parse(json.myservertime)); console.log('The system time now is: ' + sysDateTime) } }); return sysDateTime; }; The

Java SimpleDateFormat pattern for W3C XML dates with timezone [duplicate]

扶醉桌前 提交于 2019-12-17 07:26:33
问题 This question already has answers here : Java Time Zone When Parsing DateFormat (7 answers) Closed 3 years ago . I am trying to parse a W3C XML Schema date like the following "2012-05-15T07:08:09+03:00" which complies with the ISO 8601 version of the W3C XML Schema dateTime specification. In the above date, the timezone identifier is "+03:00" , but no SimpleDateFormat pattern apparently exists to represent it. If the timezone were "+0300" , then Z (uppercase) would be applicable and the

Java SimpleDateFormat pattern for W3C XML dates with timezone [duplicate]

给你一囗甜甜゛ 提交于 2019-12-17 07:26:26
问题 This question already has answers here : Java Time Zone When Parsing DateFormat (7 answers) Closed 3 years ago . I am trying to parse a W3C XML Schema date like the following "2012-05-15T07:08:09+03:00" which complies with the ISO 8601 version of the W3C XML Schema dateTime specification. In the above date, the timezone identifier is "+03:00" , but no SimpleDateFormat pattern apparently exists to represent it. If the timezone were "+0300" , then Z (uppercase) would be applicable and the

ISO time (ISO 8601) in Python

允我心安 提交于 2019-12-17 06:58:09
问题 I have a file. In Python, I would like to take its creation time, and convert it to an ISO time (ISO 8601) string while preserving the fact that it was created in the Eastern Time Zone (ET) . How do I take the file's ctime and convert it to an ISO time string that indicates the Eastern Time Zone (and takes into account daylight savings time, if necessary)? 回答1: Local to ISO 8601: import datetime datetime.datetime.now().isoformat() UTC to ISO 8601: import datetime datetime.datetime.utcnow()

How to create a .NET DateTime from ISO 8601 format

陌路散爱 提交于 2019-12-16 22:23:29
问题 I've found how to turn a DateTime into an ISO 8601 format, but nothing on how to do the reverse in C#. I have 2010-08-20T15:00:00Z , and I want to turn it into a DateTime object. I could separate the parts of the string myself, but that seems like a lot of work for something that is already an international standard. 回答1: This solution makes use of the DateTimeStyles enumeration, and it also works with Z. DateTime d2 = DateTime.Parse("2010-08-20T15:00:00Z", null, System.Globalization

Parse date-only value in ISO 8601 format in java.time (YYYY-MM-DD)

时间秒杀一切 提交于 2019-12-13 22:38:59
问题 How do I parse YYYY-MM-DD dates in modern Java? I have a Java String of a standard ISO 8601 date in the YYYY-MM-DD format, such as 2016-03-21 . How can I parse this into the modern Date-Time types in Java, the java.time classes? Note: This is intended to be a canonical post for a common question. 回答1: LocalDate.parse The java.time classes can parse ISO 8601 strings directly, with no need to specify a formatting pattern. For a date-only value, without a time of day or time zone, use the