What is this date format called? Standard format string for it?

Posted by: tfabris

What is this date format called? Standard format string for it? - 30/10/2015 20:44

My C# program must communicate with a REST API which wants me to supply dates in a format that looks something like this:

Code:
Some examples that work:

   20151001T170952%2B1000

   20130305T170030+0400



Their documentation doesn't describe the format in detail. It essentially makes a circular statement: "for your date query to work on our REST API, make sure the date is in the format that our REST API uses". Or something like that. There's no link to exactly what this format means.

It looks vaguely like ISO 8601, but when I tell C# to use ISO 8601 with the "o" format, I get something that looks different:

Code:
ISO 8601:

 2015-10-20T13:40:59.4105922-07:00



I'm temporarily going to work around it by just specifying it directly with MM DD YY etc in the right place. But I'll be worried that's wrong, and that I'm missing something.

Does anyone recognize exact precise date format? Do you know what it's called, ie, can you give it an exact canonical name that I can google for? Is there a precise format specifier for it?

Thanks!
Posted by: Shonky

Re: What is this date format called? Standard format string for it? - 31/10/2015 02:44

http://stackoverflow.com/questions/3405335/parsing-a-teamcity-java-generated-timestamp-in-net wink

I don't see any issue just manually creating the string. I don't believe it's a standard format, but it shouldn't matter if it's defined properly and everything understands.

Edit: It does appear to be part of ISO8601 "subject to agreement by communicating parties". See end of this section:
https://en.wikipedia.org/wiki/ISO_8601#Durations
Posted by: tfabris

Re: What is this date format called? Standard format string for it? - 31/10/2015 02:49

Yeah, my code seems to be working OK by manually specifying the date string format. Thanks!
Posted by: Roger

Re: What is this date format called? Standard format string for it? - 31/10/2015 10:43



Heh.
Posted by: mlord

Re: What is this date format called? Standard format string for it? - 31/10/2015 12:36

Too funny!
Posted by: tfabris

Re: What is this date format called? Standard format string for it? - 31/10/2015 18:10

Okay, I didn't notice it was you the first time.

That's hilarious. I think that might be the second or third time I've ended up searching for something on StackOverflow and finding an empegger in the results.
Posted by: tfabris

Re: What is this date format called? Standard format string for it? - 31/10/2015 18:11

How good are you with the Team City Rest API?

Oh, and have you ever spent any time working with DotCover?

I might want to ask you more specific questions. :-)
Posted by: canuckInOR

Re: What is this date format called? Standard format string for it? - 05/11/2015 20:45

A little late to the party, but...

Originally Posted By: tfabris
It looks vaguely like ISO 8601

This doesn't just look vaguely like ISO 8601, it is ISO 8601, which specifies two formats -- a basic format (as above), and an extended format that uses separators for readability. The basic format only requires separators when necessary to remove ambiguity. For example, YYYY-MM requires the hyphen, even in the basic format.

Originally Posted By: tfabris
, but when I tell C# to use ISO 8601 with the "o" format, I get something that looks different:

Code:
ISO 8601:

 2015-10-20T13:40:59.4105922-07:00

I'm temporarily going to work around it by just specifying it directly with MM DD YY etc in the right place. But I'll be worried that's wrong, and that I'm missing something.

You won't be missing anything. If you read the docs for the "o" format, it says
Originally Posted By: MSDN

The "O" or "o" standard format specifier corresponds to the "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK" custom format string for DateTime values and to the "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz" custom format string for DateTimeOffset values. In this string, the pairs of single quotation marks that delimit individual characters, such as the hyphens, the colons, and the letter "T", indicate that the individual character is a literal that cannot be changed.

You can use a custom format string that removes the separators and fractional seconds (you'll probably still want the TZ info, though), and still be ISO 8601 compliant.
Posted by: tfabris

Re: What is this date format called? Standard format string for it? - 06/11/2015 04:58

Awesome! Thank you!