/// <summary> /// Parse a date and time for format-date() /// </summary> /// <param name="d"></param> /// <returns></returns> public static ExsltDateTime ParseDateTime(string d) { // First try any of the classes in ParseDate try { return ParseDate(d); } catch (FormatException) { } try { TimeTZ t = new TimeTZ(d); return t; } catch (FormatException) { } try { MonthDay t = new MonthDay(d); return t; } catch (FormatException) { } try { Month t = new Month(d); return t; } catch (FormatException) { } // Finally day -- don't catch the exception { Day t = new Day(d); return t; } }
/// <summary> /// Implements the following function /// string date:time(string) /// </summary> /// <returns>The time part of the specified date or the empty string if the /// date is invalid</returns> public string time(string d) { try { TimeTZ t = new TimeTZ(d); return t.ToString(); } catch (FormatException) { return ""; } }
/// <summary> /// Implements the following function /// string date:time() /// </summary> /// <returns>The current time</returns> public string time() { TimeTZ t = new TimeTZ(); return t.ToString(); }
/// <summary> /// Implements the following function /// number date:second-in-minute(string) /// </summary> /// <returns>The seconds of the minute of the specified time or NaN if the /// date is invalid</returns> public double secondInMinute(string d) { try { TimeTZ date = new TimeTZ(d); return date.d.Second; } catch (FormatException) { return System.Double.NaN; } }
/// <summary> /// Implements the following function /// number date:minute-in-hour(string) /// </summary> /// <returns>The minute of the hour of the specified time or NaN if the /// date is invalid</returns> public double minuteInHour(string d) { try { TimeTZ date = new TimeTZ(d); return date.d.Minute; } catch (FormatException) { return System.Double.NaN; } }
/// <summary> /// Implements the following function /// number date:hour-in-day(string) /// </summary> /// <returns>The current hour of the specified time or NaN if the /// date is invalid</returns> public double hourInDay(string d) { try { TimeTZ date = new TimeTZ(d); return date.d.Hour; } catch (FormatException) { return System.Double.NaN; } }