note
	description: "Code used by the DATE/TIME to STRING conversion"
	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 
	DATE_TIME_CODE

inherit
	CODE_VALIDITY_CHECKER

	DEBUG_OUTPUT

create 
	make

feature -- Creation

	make (v: STRING_8)
			-- Create code.
		require
			v_exists: v /= Void
			v_is_code: is_code (v)
		do
			set_value (v)
		ensure
			value_set: value.same_string (v)
		end
	
feature -- Status report

	is_separator_code: BOOLEAN
		do
			inspect type
			when Colon_type_code, Slash_type_code, Minus_type_code, Comma_type_code, Space_type_code, Dot_type_code then
				Result := True
			else
			end
		end

	is_text: BOOLEAN
			-- Has the code a string value?

	is_numeric: BOOLEAN
			-- Has the code a numeric value?
	
feature -- Change

	set_value (v: STRING_8)
			-- Set all the attributes such as
			-- Value, count_max, etc.
		require
			v_exists: v /= Void
			v_is_code: is_code (v)
		local
			l_name: like name
		do
			value := v.twin
			if is_day (value) then
				count_max := 2
				count_min := 1
				l_name := "day-numeric"
				value_max := 31
				value_min := 1
				is_text := False
				is_numeric := True
				type := Day_numeric_type_code.to_integer_32
			elseif is_day0 (value) then
				count_max := 2
				count_min := 2
				l_name := "day-numeric-on-2-digits"
				value_max := 31
				value_min := 1
				is_text := False
				is_numeric := True
				type := Day_numeric_on_2_digits_type_code.to_integer_32
			elseif is_day_text (value) then
				count_max := 3
				count_min := 3
				l_name := "day-text"
				value_max := 7
				value_min := 1
				is_text := True
				is_numeric := False
				type := Day_text_type_code.to_integer_32
			elseif is_year4 (value) then
				count_max := 4
				count_min := 4
				l_name := "year-on-4-digits"
				is_text := False
				is_numeric := True
				type := Year_on_4_digits_type_code.to_integer_32
				value_max := -1
				value_min := -1
			elseif is_year2 (value) then
				count_max := 2
				count_min := 2
				l_name := "year-on-2-digits"
				is_text := False
				is_numeric := True
				type := Year_on_2_digits_type_code.to_integer_32
				value_max := -1
				value_min := -1
			elseif is_month (value) then
				count_max := 2
				count_min := 1
				l_name := "month-numeric"
				value_max := 12
				value_min := 1
				is_text := False
				is_numeric := True
				type := Month_numeric_type_code.to_integer_32
			elseif is_month0 (value) then
				count_max := 2
				count_min := 2
				l_name := "month-numeric-on-2-digits"
				value_max := 12
				value_min := 1
				is_text := False
				is_numeric := True
				type := Month_numeric_on_2_digits_type_code.to_integer_32
			elseif is_month_text (value) then
				count_max := 3
				count_min := 3
				l_name := "month-text"
				value_max := 12
				value_min := 1
				is_text := True
				is_numeric := False
				type := Month_text_type_code.to_integer_32
			elseif is_hour (value) then
				count_max := 2
				count_min := 1
				l_name := "hour-numeric"
				value_max := 24
				value_min := 0
				is_text := False
				is_numeric := True
				type := Hour_numeric_type_code.to_integer_32
			elseif is_hour0 (value) then
				count_max := 2
				count_min := 2
				l_name := "hour-numeric-on-2-digits"
				value_max := 24
				value_min := 0
				is_text := False
				is_numeric := True
				type := Hour_numeric_on_2_digits_type_code.to_integer_32
			elseif is_hour12 (value) then
				count_max := 2
				count_min := 1
				l_name := "hour-12-clock-scale"
				value_max := 12
				value_min := 0
				is_text := False
				is_numeric := True
				type := Hour_12_clock_scale_type_code.to_integer_32
			elseif is_minute (value) then
				count_max := 2
				count_min := 1
				l_name := "minute-numeric"
				value_max := 59
				value_min := 0
				is_text := False
				is_numeric := True
				type := Minute_numeric_type_code.to_integer_32
			elseif is_minute0 (value) then
				count_max := 2
				count_min := 2
				l_name := "minute-numeric-on-2-digits"
				value_max := 59
				value_min := 0
				is_text := False
				is_numeric := True
				type := Minute_numeric_on_2_digits_type_code.to_integer_32
			elseif is_second (value) then
				count_max := 2
				count_min := 1
				l_name := "second-numeric"
				value_max := 59
				value_min := 0
				is_text := False
				is_numeric := True
				type := Second_numeric_type_code.to_integer_32
			elseif is_second0 (value) then
				count_max := 2
				count_min := 2
				l_name := "second-numeric-on-2-digits"
				value_max := 59
				value_min := 0
				is_text := False
				is_numeric := True
				type := Second_numeric_on_2_digits_type_code.to_integer_32
			elseif is_fractional_second (value) then
				count_max := value.substring (3, value.count).to_integer
				count_min := 1
				l_name := "fractional-second-numeric"
				is_text := False
				is_numeric := True
				type := Fractional_second_numeric_type_code.to_integer_32
				value_max := -1
				value_min := -1
			elseif is_colon (value) then
				count_max := 1
				count_min := 1
				l_name := "colon"
				is_text := True
				is_numeric := False
				type := Colon_type_code.to_integer_32
			elseif is_slash (value) then
				count_max := 1
				count_min := 1
				l_name := "slash"
				is_text := True
				is_numeric := False
				type := Slash_type_code.to_integer_32
			elseif is_minus (value) then
				count_max := 1
				count_min := 1
				l_name := "minus"
				is_text := True
				is_numeric := False
				type := Minus_type_code.to_integer_32
			elseif is_comma (value) then
				count_max := 1
				count_min := 1
				l_name := "comma"
				is_text := True
				is_numeric := False
				type := Comma_type_code.to_integer_32
			elseif is_space (value) then
				count_max := 1
				count_min := 1
				l_name := "space"
				is_text := True
				is_numeric := False
				type := Space_type_code.to_integer_32
			elseif is_dot (value) then
				count_max := 1
				count_min := 1
				l_name := "dot"
				is_text := True
				is_numeric := False
				type := Dot_type_code.to_integer_32
			elseif is_meridiem (value) then
				count_max := 2
				count_min := 2
				l_name := "meridiem"
				is_text := True
				is_numeric := False
				type := Meridiem_type_code.to_integer_32
			else
				check
					is_hour12_0: is_hour12_0 (value)
				end
				count_max := 2
				count_min := 2
				l_name := "hour-12-clock-scale-on-2-digits"
				value_max := 12
				value_min := 0
				is_text := False
				is_numeric := True
				type := Hour_12_clock_scale_on_2_digits_type_code.to_integer_32
			end
			name := l_name
		ensure
			value_set: value.same_string (v)
		end
	
feature -- Attributes

	value: STRING_8
			-- String code

	count_max: INTEGER_32
			-- Count max of the real value

	count_min: INTEGER_32
			-- Count min of the real value

	name: STRING_8
			-- Name of the code

	value_max: INTEGER_32
			-- Max of the real value

	value_min: INTEGER_32
			-- Min of the real value

	type: INTEGER_32
			-- Type number.
	
feature -- Output

	debug_output: STRING_8
			-- String that should be displayed in debugger to represent Current.
		do
			create Result.make_empty
			Result.append_integer (type)
			Result.append (" -> ")
			Result.append (name)
		end
	
feature {FIND_SEPARATOR_FACILITY} -- Implementation

	Day_numeric_type_code: NATURAL_8 = 1

	Day_numeric_on_2_digits_type_code: NATURAL_8 = 2

	Day_text_type_code: NATURAL_8 = 3

	Year_on_4_digits_type_code: NATURAL_8 = 4

	Year_on_2_digits_type_code: NATURAL_8 = 5

	Month_numeric_type_code: NATURAL_8 = 6

	Month_numeric_on_2_digits_type_code: NATURAL_8 = 7

	Month_text_type_code: NATURAL_8 = 8

	Hour_numeric_type_code: NATURAL_8 = 9

	Hour_numeric_on_2_digits_type_code: NATURAL_8 = 10

	Hour_12_clock_scale_type_code: NATURAL_8 = 11

	Hour_12_clock_scale_on_2_digits_type_code: NATURAL_8 = 12

	Minute_numeric_type_code: NATURAL_8 = 13

	Minute_numeric_on_2_digits_type_code: NATURAL_8 = 14

	Second_numeric_type_code: NATURAL_8 = 15

	Second_numeric_on_2_digits_type_code: NATURAL_8 = 16

	Fractional_second_numeric_type_code: NATURAL_8 = 17

	Colon_type_code: NATURAL_8 = 18

	Slash_type_code: NATURAL_8 = 19

	Minus_type_code: NATURAL_8 = 20

	Comma_type_code: NATURAL_8 = 21

	Space_type_code: NATURAL_8 = 22

	Dot_type_code: NATURAL_8 = 23

	Meridiem_type_code: NATURAL_8 = 24
			-- Type code constants
	
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 DATE_TIME_CODE

Generated by ISE EiffelStudio