示例#1
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;
				}
			}
示例#2
0
		/// <summary>
		/// Internal function to format the date based on a date, rather than a string
		/// </summary>
		/// <returns>The formtted date and time as a ISO8601 string</returns>        

		internal string dateTimeImpl(DateTimeTZ dtz)
		{
			return dtz.ToString();
		}
示例#3
0
		/// <summary>
		/// Implements the following function
		///   string date:date-time()
		/// </summary>
		/// <returns>The current date and time or the empty string if the 
		/// date is invalid </returns>        
		public string dateTime(string s)
		{
			try
			{
				DateTimeTZ d = new DateTimeTZ(s);
				return dateTimeImpl(d);
			}
			catch (FormatException)
			{
				return "";
			}
		}
示例#4
0
		/// <summary>
		/// Implements the following function
		///   string date:date-time()
		/// Output format is ISO 8601 (YYYY-MM-DDThh:mm:ss{Z | {+ | -}zz:zz}).
		/// YYYY - year with century
		/// MM - month in numbers with leading zero
		/// DD - day in numbers with leading zero
		/// T - the letter T
		/// hh - hours in numbers with leading zero (00-23).
		/// mm - minutes in numbers with leading zero (00-59).
		/// ss - seconds in numbers with leading zero (00-59).
		/// +/-zzzz - time zone expressed as hours and minutes from UTC.
		///		If UTC, then this is the letter Z
		///		If east of Greenwich, then -zz:zz (e.g. Pacific standard time is -08:00)
		///		If west of Greenwich, then +zz:zz (e.g. Tokyo is +09:00)
		/// </summary>
		/// <returns>The current time.</returns>		
		public string dateTime()
		{
			DateTimeTZ d = new DateTimeTZ();
			return dateTimeImpl(d);
		}