title: SCORM 2004 Time Format - Regular Expression?
body: <p>I am building a SCORM 2004 javascript API for an LMS, and one of the SCORM 2004 requirements is that timeintervals passed into it must follow the following format.  Does anyone know what the regular expression of this would be?  I am trying to wrap my mind around it, but to no avail.  Note: P must always be the first character.</p>
  
  <blockquote>
    <p>P[yY][mM][dD][T[hH][nM][s[.s]S]]
    where:</p>
    
    <ul>
    <li>y: The number of years (integer, >= 0, not restricted)</li>
    <li>m: The number of months (integer, >=0, not restricted)</li>
    <li>d: The number of days (integer, >=0, not restricted)</li>
    <li>h: The number of hours (integer, >=0, not restricted)</li>
    <li>n: The number of minutes (integer, >=0, not restricted)</li>
    <li>s: The number of seconds or fraction of seconds (real or integer, >=0, not
    restricted). If fractions of a second are used, SCORM further restricts the string to
    a maximum of 2 digits (e.g., 34.45 – valid, 34.45454545 – not valid).</li>
    <li>The character literals designators P, Y, M, D, T, H, M and S shall appear if the
    corresponding non-zero value is present.</li>
    <li>Zero-padding of the values shall be supported. Zero-padding does not change the
    integer value of the number being represented by a set of characters. For
    example, PT05H is equivalent to PT5H and PT000005H.</li>
    </ul>
    
    <p>Example - </p>
    
    <ul>
    <li>P1Y3M2DT3H indicates a period of time of 1 year, 3 months, 2 days and 3
    hours</li>
    <li>PT3H5M indicates a period of time of 3 hours and 5 minutes</li>
    </ul>
  </blockquote>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have added some additional standards that must be kept - </p>
  
  <blockquote>
    <ul>
    <li>The designator P shall be present</li>
    <li>If the value of years, months, days, hours, minutes or seconds is
    zero, the value and corresponding
    character literal designation may be
    omitted, but at least one character
    literal designator and value shall be
    present in addition to the designator
    P</li>
    <li>The designator T shall be omitted if all of the time components (hours,
    minutes and seconds) are not used. A
    zero value may be used with any of the
    time components (e.g., PT0S)</li>
    </ul>
  </blockquote>