indexing
	description: "Parser facility for dates and times"
	status: "See note at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	DATE_TIME_PARSER

create 

	make (c: HASH_TABLE [DATE_TIME_CODE, INTEGER])
			-- Create parser with date/time code c, months array m,
			-- days array d, and base century b.
		require
			code_exists: c /= void
		ensure
			code_set: code = c

feature -- Access

	day: INTEGER
			-- Day part of source_string
		require
			value_parsed: parsed

	day_text: STRING
			-- Text representation of day
		require
			value_parsed: parsed

	fine_second: DOUBLE
			-- Seconds part of source_string
		require
			value_parsed: parsed

	hour: INTEGER
			-- Hour part of source_string
		require
			value_parsed: parsed

	minute: INTEGER
			-- Minute part of source_string
		require
			value_parsed: parsed

	month: INTEGER
			-- Month part of source_string
		require
			value_parsed: parsed

	source_string: STRING
			-- String to be parsed

	year: INTEGER
			-- Year part of source_string
		require
			value_parsed: parsed
	
feature -- Status report

	is_date: BOOLEAN
			-- Does source_string contain a DATE?
		require
			string_parsed: parsed

	is_date_time: BOOLEAN
			-- Does source_string contain a DATE_TIME?
		require
			string_parsed: parsed

	is_set_up: BOOLEAN
			-- Has parser been set up completely?

	is_time: BOOLEAN
			-- Does source_string contain a TIME?
		require
			string_parsed: parsed

	is_value_valid: BOOLEAN
			-- Is parsed value valid?

	parsed: BOOLEAN
			-- Has source_string been parsed?
	
feature -- Status setting

	set_base_century (c: INTEGER)
			-- Set base century to c.
		require
			base_century_valid: c /= 0 and (c \\ 100 = 0)
		ensure
			base_century_set: base_century = c

	set_day_array (d: ARRAY [STRING])
			-- Set day array to d.
		require
			not_void: d /= void
		ensure
			days_set: days = d

	set_month_array (m: ARRAY [STRING])
			-- Set month array to m.
		require
			not_void: m /= void
		ensure
			months_set: months = m

	set_source_string (s: STRING)
			-- Assign s to source_string.
		require
			non_empty_string: s /= void and then not s.is_empty
		ensure
			source_set: source_string = s
			not_parsed: not parsed
	
feature -- Basic operations

	parse
			-- Parse source_string.
		require
			setup_complete: is_set_up
		ensure
			string_parsed: parsed
	
invariant

	valid_value_definition: is_value_valid = (parsed and then (is_date or is_time or is_date_time))
	valid_value_implies_parsing: is_value_valid implies parsed
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class DATE_TIME_PARSER