Beispiel #1
0
		/// <summary>
		/// Implements the following function
		///   number date:year(string)
		/// </summary>
		/// <returns>The year part of the specified date or the empty string if the 
		/// date is invalid</returns>
		/// <remarks>Does not support dates in the format of the xs:yearMonth or 
		/// xs:gYear types</remarks>        
		public double year(string d)
		{
			try
			{
				YearTZ date = new YearTZ(d);
				return date.d.Year;
			}
			catch (FormatException)
			{
				return System.Double.NaN;
			}
		}
Beispiel #2
0
			/// <summary>
			/// Initialize the structure with the current date, time and timezone
			/// </summary>
			public static ExsltDateTime ParseDate(string d)
			{
				// Try each potential class, from most specific to least specific.

				// First DateTimeTZ
				try
				{
					DateTimeTZ t = new DateTimeTZ(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Next Date
				try
				{
					DateTZ t = new DateTZ(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Next YearMonth
				try
				{
					YearMonth t = new YearMonth(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Finally Year -- don't catch the exception for the last type
				{
					YearTZ t = new YearTZ(d);
					return t;
				}
			}