Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#365185 - 30/10/2015 20:44 What is this date format called? Standard format string for it?
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
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!
_________________________
Tony Fabris

Top
#365186 - 31/10/2015 02:44 Re: What is this date format called? Standard format string for it? [Re: tfabris]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
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


Edited by Shonky (31/10/2015 02:47)
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#365187 - 31/10/2015 02:49 Re: What is this date format called? Standard format string for it? [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Yeah, my code seems to be working OK by manually specifying the date string format. Thanks!
_________________________
Tony Fabris

Top
#365191 - 31/10/2015 10:43 Re: What is this date format called? Standard format string for it? [Re: Shonky]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
_________________________
-- roger

Top
#365192 - 31/10/2015 12:36 Re: What is this date format called? Standard format string for it? [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Too funny!

Top
#365193 - 31/10/2015 18:10 Re: What is this date format called? Standard format string for it? [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
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.
_________________________
Tony Fabris

Top
#365194 - 31/10/2015 18:11 Re: What is this date format called? Standard format string for it? [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
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. :-)
_________________________
Tony Fabris

Top
#365220 - 05/11/2015 20:45 Re: What is this date format called? Standard format string for it? [Re: tfabris]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
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.

Top
#365224 - 06/11/2015 04:58 Re: What is this date format called? Standard format string for it? [Re: canuckInOR]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Awesome! Thank you!
_________________________
Tony Fabris

Top