What does DateTimeStyles.RoundtripKind enumeration mean?

asked9 years ago
last updated3 years ago
viewed14.4k times
Up Vote21Down Vote

I was reading this answer here where I came across this enumeration value DateTimeStyles.RoundtripKind. I'm trying to understand it now. I looked into MSDN docs here which says:

The DateTimeKind field of a date is preserved when a DateTime object is converted to a string using the "o" or "r" standard format specifier, and the string is then converted back to a DateTime object. The timestamp pointed by input variable in the post I referred in the previous paragraph is as below:

<timestamp time='2016-09-16T13:45:30'>

I ran her code and it works. Now it has become bit messy to correlate all the information I have:

  1. The above time stamp contains some identifier T
  2. The MSDN documentation talks about o and r format specifiers which it doesn't tell what it is?
  3. If you go into dig more details on DateTimeKind enumeration on the MSDN link I've quoted above it says nothing about o and r format specifiers. Here is the link which says: Member Name | Description

Local | The time represented is local time. Unspecified | The time represented is not specified as either local time or Coordinated Universal Time (UTC). Utc | The time represented is UTC.

So can someone help me understand DateTimeStyles.RoundtripKind enumeration and how it works?