note
	description: "Facility routines to check the validity of a DATE_TIME_CODE"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date: 2017-03-29 12:26:46 +0000 (Wed, 29 Mar 2017) $"
	revision: "$Revision: 100065 $"

class interface
	CODE_VALIDITY_CHECKER

create 
	default_create

feature -- Preconditions

	is_code (s: STRING_8): BOOLEAN
			-- Is the string a code?
		require
			s_exists: s /= Void

	is_day (s: STRING_8): BOOLEAN
			-- Is the code a day-numeric?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("dd")

	is_day0 (s: STRING_8): BOOLEAN
			-- Is the code a day-numeric
			-- Padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]dd")

	is_day_text (s: STRING_8): BOOLEAN
			-- Is the code a day-text?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("ddd")

	is_year4 (s: STRING_8): BOOLEAN
			-- Is the code a year-numeric
			-- On 4 figures?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("yyyy")

	is_year2 (s: STRING_8): BOOLEAN
			-- Is the code a year-numeric
			-- On 2 figures?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("yy")

	is_month (s: STRING_8): BOOLEAN
			-- Is the code a month-numeric?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("mm")

	is_month0 (s: STRING_8): BOOLEAN
			-- Is the code a month-numeric
			-- Padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]mm")

	is_month_text (s: STRING_8): BOOLEAN
			-- Is the code a month-text?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("mmm")

	is_hour (s: STRING_8): BOOLEAN
			-- Is the code a 24-hour-clock-scale?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("hh")

	is_hour0 (s: STRING_8): BOOLEAN
			-- Is the code a 24-hour-clock-scale
			-- Padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]hh")

	is_hour12 (s: STRING_8): BOOLEAN
			-- Is the code a 12-hour-clock-scale?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("hh12")

	is_hour12_0 (s: STRING_8): BOOLEAN
			-- Is the code a 12-hour-clock-scale padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]hh12")

	is_minute (s: STRING_8): BOOLEAN
			-- Is the code a minute-numeric?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("mi")

	is_minute0 (s: STRING_8): BOOLEAN
			-- Is the code a minute-numeric
			-- Padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]mi")

	is_second (s: STRING_8): BOOLEAN
			-- Is the code a second-numeric?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("ss")

	is_second0 (s: STRING_8): BOOLEAN
			-- Is the code a second-numeric
			-- Padded with zero?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("[0]ss")

	is_fractional_second (s: STRING_8): BOOLEAN
			-- Is the code a fractional-second
			-- With precision to n figures?
		require
			s_exists: s /= Void
		ensure
			definition: Result = (s.count > 2 and then (s.substring (1, 2).same_string ("ff") and s.substring (3, s.count).is_integer))

	is_colon (s: STRING_8): BOOLEAN
			-- Is the code a separator-colomn?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string (":")

	is_slash (s: STRING_8): BOOLEAN
			-- Is the code a separator-slash?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("/")

	is_minus (s: STRING_8): BOOLEAN
			-- Is the code a separator-minus?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string ("-")

	is_comma (s: STRING_8): BOOLEAN
			-- Is the code a separator-coma?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string (",")

	is_space (s: STRING_8): BOOLEAN
			-- Is the code a separator-space?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string (" ")

	is_dot (s: STRING_8): BOOLEAN
			-- Is the code a separator-dot?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.same_string (".")

	is_separator (s: STRING_8): BOOLEAN
			-- Is the code a separator?
		require
			s_exists: s /= Void
		ensure
			definition: Result = is_slash (s) or else is_colon (s) or else is_minus (s) or else is_comma (s) or else is_space (s) or else is_dot (s)

	is_meridiem (s: STRING_8): BOOLEAN
			-- Is the code a meridiem notation?
		require
			s_exists: s /= Void
		ensure
			definition: Result = s.as_upper.same_string ("AM") or s.as_upper.same_string ("PM")
	
note
	copyright: "Copyright (c) 1984-2017, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class CODE_VALIDITY_CHECKER

Generated by ISE EiffelStudio