                 // of the locale.
                 offset = (new Date(year, month, day, hour, minute, second)).timezoneOffset;
                 trace("DateParse.parseXSDateTime: Warning: Timezone not " +
-                      "specified. Timezone set to " + (offset / -60) +
-                      ". String was: '" + xsDateTime + "'");
+                    "specified. Timezone set to " + (offset / -60) +
+                    ". String was: '" + xsDateTime + "'");
             }
 
             if (anyIsNaN(year, month, day, hour, minute, second))
             {
+                throw new ArgumentError("Not a valid xsd:datetime string");
                 trace("DateParse.parseXSDateTime: Warning: ParseInt " +
-                      "failed. String was: '" + xsDateTime + "'");
-                return null;
+                    "failed. String was: '" + xsDateTime + "'");
             }
             else
             {
-                epoch = Date.UTC(year, month, day,
-                                 hour, minute, second, ms) + offset * TimeUnits.MINUTE;
-            }
-        }
-        else
-        {
-            trace("DateParse.parseXSDateTime: " + "RegExp failed. String " +
-                  "was: '" + xsDateTime + "'");
-            return null;
+                epoch = Date.UTC(year, month, day, hour, minute, second, ms)
+                    + offset * TimeUnits.MINUTE;
+            }
+        }
+        else
+        {
+            throw new ArgumentError("Not a valid xsd:datetime string");
         }
 
         return new Date(epoch);

    {
        var str:String;

        str = StringUtil.padLeft(date.fullYearUTC, 4, "0")  + "-" +
              StringUtil.padLeft(date.monthUTC + 1, 2, "0") + "-" +
              StringUtil.padLeft(date.dateUTC, 2, "0") + "T" +

              StringUtil.padLeft(date.hoursUTC, 2, "0") + ":" +
              StringUtil.padLeft(date.minutesUTC, 2, "0") + ":" +
              StringUtil.padLeft(date.secondsUTC, 2, "0") + "Z";

        return str;
    }

     * returns the result in negative minutes, which matches the units
     * used by Date.timezoneOffset
     */
    private static function parseXSDOffset(xsOffset:String):Number
    {
        var sign:String;
        var hours:Number;
        var minutes:Number;

        if (xsOffset.toLowerCase().charAt(0) == 'z')
        {
            return 0;
        }
        else
        {
            sign = xsOffset.charAt(0);
            if ('+-'.indexOf(sign) == -1)
            {
                return Number.NaN;
            }
            hours = parseInt(xsOffset.substr(1, 2));
            minutes = parseInt(xsOffset.substr(4, 2));

            minutes += hours * 60;
            if (sign == '-') minutes = -minutes;
