iso8601

Annoying javascript timezone adjustment issue

时间秒杀一切 提交于 2019-11-27 09:06:45
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 problem is that when I check the console, it still shows wrong time... It is still affected by the

Regex and ISO8601 formatted DateTime

不打扰是莪最后的温柔 提交于 2019-11-27 07:24:07
I have a DateTime string ISO8601 formated 2012-10-06T04:13:00+00:00 and the following Regex which does not match this string #(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})\+(\d{2})\:(\d{2})# I can't figure out why it does not match. I escaped metacharacters, for me it seems to be OK. http://jsfiddle.net/5n5vk/2/ EDIT : The right way: http://jsfiddle.net/5n5vk/3/ Don't quote the regex when specifying a regex in js. Forward slash is enough. alert($('#datepicker').val()); if($('#datepicker').val().match( /(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/ )) { alert('ok');

Parsing ISO 8601 with timezone to .NET datetime

久未见 提交于 2019-11-27 06:00:09
问题 I have an ISO 8601 timestamp in the format: YYYY-MM-DDThh:mm:ss[.nnnnnnn][{+|-}hh:mm] YYYY-MM-DDThh:mm:ss[{+|-}hh:mm] Examples: 2013-07-03T02:16:03.000+01:00 2013-07-03T02:16:03+01:00 How can I parse it to a .NET Framework DateTime with correct TimeZone supplied? The DateTime.TryParse doesn't work because the trailing info regarding the TimeZone . 回答1: You should be able to format it using DateTimeOffset and the K custom format specifier. You can then convert that to a DateTime afterwards if

Sort ISO 8601 dates forward or backwards

心已入冬 提交于 2019-11-27 05:54:01
问题 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! 回答1: It depends on whether or not

What mode for MySQL WEEK() complies with ISO 8601

只愿长相守 提交于 2019-11-27 05:33:36
问题 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

How can I convert a date value in ISO 8601 format to a date object in JavaScript?

 ̄綄美尐妖づ 提交于 2019-11-27 04:48:17
I've been trying to convert a date value into a more readable format. To do that, I'm trying to parse the date using the JavaScript Date.parse() method. That however does not work on the input (eg: "2007-09-21T14:15:34.058-07:00" ) that I have. The end goal is to output a date string like "January 30th, 2008 @ 2:15PM" . Any ideas? Try http://www.datejs.com/ . It is a JavaScript Date Library with an extended Date.parse method and a Date.parseExact method, which lets you specify a format string. See DateJS APIDocumentation . some You should probably use the datejs that f3lix recommended, however

Current time in ISO 8601 format

独自空忆成欢 提交于 2019-11-27 04:43:16
问题 For logging purposes, how can an R script get the current date and time, in the UTC time zone, as an ISO 8601 string in this format: 2015-12-31T14:26:56.600374+00:00 as.POSIXlt seems to be the solution, and the documentation claims that it accepts a format parameter, but I can't make that work (on R version 3.1.3): > as.POSIXlt(Sys.time(), "UTC", "%Y-%m-%dT%H:%M:%S") [1] "2015-04-08 14:37:58 UTC" > as.POSIXlt(Sys.time(), tz="UTC", format="%Y-%m-%dT%H:%M:%S") [1] "2015-04-08 14:38:02 UTC" > as

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

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:22:20
This question already has an answer here: Java Time Zone When Parsing DateFormat 7 answers 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 SimpleDateFormat pattern would be yyyy-MM-dd'T'HH:mm:ssZ Similarly, if the timezone were "GMT+03:00" , then z (lowercase) would be

How to parse an ISO-8601 duration in Objective C?

半世苍凉 提交于 2019-11-27 04:06:45
I'm looking for an easy way to parse a string that contains an ISO-8601 duration in Objective C. The result should be something usable like a NSTimeInterval . An example of an ISO-8601 duration: P1DT13H24M17S , which means 1 day, 13 hours, 24 minutes and 17 seconds. If you know exactly which fields you'll be getting, you can use one invocation of sscanf() : const char *stringToParse = ...; int days, hours, minutes, seconds; NSTimeInterval interval; if(sscanf(stringToParse, "P%dDT%dH%dM%sS", &days, &hours, &minutes, &seconds) == 4) interval = ((days * 24 + hours) * 60 + minutes) * 60 + seconds;

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

心已入冬 提交于 2019-11-27 00:15:49
问题 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 回答1: 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