4
{
 "kind": "youtube#videoListResponse",
 "etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/ny1S4th-ku477VARrY_U4tIqcTw\"",
 "items": [
  {

   "id": "9bZkp7q19f0",
   "kind": "youtube#video",
   "etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/HN8ILnw-DBXyCcTsc7JG0z51BGg\"",
   "contentDetails": {
    "duration": "PT4M13S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true,
    "regionRestriction": {
     "blocked": [
      "DE"
     ]
    }
   }
  }
 ]
}

Youtube API v3 provides its video durations in this format "duration": "PT4M13S" Is this a standard time format? I'm trying to get a user friendly format using Objective-C. I would like to know if this is a Objective-C DateTime class supported format. If not what are those P,T, charactors stands for?

Rukshan
  • 7,902
  • 6
  • 43
  • 61

2 Answers2

10

That is an ISO 8601 time format. PT indicates that we are dealing with a time peroid. H, M, S and similar ones are obviously the duration in hours, minutes and seconds, etc. I am not sure if Objective-C is able to handle this natively, but you may be able to find something useful knowing how it works.

jwueller
  • 30,582
  • 4
  • 66
  • 70
  • 2
    Cocoa can handle it: [Is there a simple way of converting an ISO8601 timestamp to a formatted `NSDate`?](http://stackoverflow.com/q/2201216) – jscs Mar 30 '13 at 17:54
0

this might help a bit, nevertheless this this an overkill, just to show video length.

http://en.wikipedia.org/wiki/ISO_8601#Durations

Yene Mulatu
  • 2,226
  • 1
  • 17
  • 13