What does 'PT' prefix stand for in Duration?

Daneel Yaitskov picture Daneel Yaitskov · Jul 4, 2018 · Viewed 22.1k times · Source

I am trying to use the Duration class instead of long. It has superior literal syntax. I like its flexibility, though it looks weird.

"PT10S" means 10 seconds, what is the problem to accept "10 seconds"?! Okay never mind.

I am just curious why PT prefix has been chosen (not "DU" e.g.) and why any prefix is better here rather than nothing?

Answer

RobAu picture RobAu · Jul 4, 2018

As can be found on the page Jesper linked to (ISO-8601 - Data elements and interchange formats – Information interchange – Representation of dates and times)

P is the duration designator (for period) placed at the start of the duration representation.
Y is the year designator that follows the value for the number of years.
M is the month designator that follows the value for the number of months.
W is the week designator that follows the value for the number of weeks.
D is the day designator that follows the value for the number of days.
T is the time designator that precedes the time components of the representation.

So P means 'Period' and because there are no date-components it only has a 'Time'.

You could interpret this as 'Period of Time'

The 'why' this was chosen, you have to ask the ISO members that wrote the standard, but my guess is that it is easier to parse. (short and unambigious)