Esempio n. 1
0
			/// <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;
				}
			}
Esempio n. 2
0
		/// <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 "";
			}
		}
Esempio n. 3
0
		/// <summary>
		/// Implements the following function
		///   string date:time()
		/// </summary>
		/// <returns>The current time</returns>        
		public string time()
		{
			TimeTZ t = new TimeTZ();
			return t.ToString();
		}
Esempio n. 4
0
		/// <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;
			}
		}
Esempio n. 5
0
		/// <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;
			}
		}
Esempio n. 6
0
		/// <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;
			}
		}