note
	description: "DATE/TIME to STRING conversion"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date: 2018-04-28 20:34:01 +0000 (Sat, 28 Apr 2018) $"
	revision: "$Revision: 101689 $"

class interface
	DATE_TIME_CODE_STRING

create 
	make

feature -- Creation

	make (s: STRING_8)
			-- Create code descriptors and hash-table from s.
		require
			s_exists: s /= Void
		ensure
			value_set: value /= Void
			base_century_set: base_century < 0 and (base_century \\ 100 = 0)
	
feature -- Attributes

	value: HASH_TABLE [DATE_TIME_CODE, INTEGER_32]
			-- Hash-table representing the code string.

	name: STRING_8
			-- Name of the code string.

	base_century: INTEGER_32
			-- Base century, used when interpreting 2-digit year
			-- specifications.
	
feature -- Status report

	is_date (s: STRING_8): BOOLEAN
			-- Does s contain a DATE?
		require
			non_empty_string: s /= Void and then not s.is_empty

	is_time (s: STRING_8): BOOLEAN
			-- Does s contain a TIME?
		require
			non_empty_string: s /= Void and then not s.is_empty

	is_date_time (s: STRING_8): BOOLEAN
			-- Does s contain a DATE_TIME?
		require
			non_empty_string: s /= Void and then not s.is_empty

	is_value_valid (s: STRING_8): BOOLEAN
			-- Does s contain a valid date or time as string representation?
		require
			non_empty_string: s /= Void and then not s.is_empty

	separators_used: BOOLEAN
			-- Does the code string contain any separators?
	
feature -- Status setting

	set_base_century (c: INTEGER_32)
			-- Set base century to c.
		require
			base_valid: c > 0 and (c \\ 100 = 0)
		ensure
			base_century_set: base_century = c
	
feature -- Interface

	correspond (s: STRING_8): BOOLEAN
			-- Does the user string s correspond to the code string?
		require
			s_exists: s /= Void

	create_string (date_time: DATE_TIME): STRING_8
			-- Create the output of date_time according to the code string.
		require
			non_void: date_time /= Void
		ensure
			string_exists: Result /= Void
			string_correspond: correspond (Result)

	create_date_string (date: DATE): STRING_8
			-- Create the output of date according to the code string.
		require
			date_exists: date /= Void
		ensure
			string_exists: Result /= Void
			string_correspond: correspond (Result)

	create_time_string (time: TIME): STRING_8
			-- Create the output of time according to the code string.
		require
			time_exists: time /= Void
		ensure
			string_exists: Result /= Void
			string_correspond: correspond (Result)

	create_date_time (s: STRING_8): DATE_TIME
			-- Create DATE_TIME according to s.
		require
			s_exist: s /= Void
			is_precise: precise
			s_correspond: correspond (s)
			valid: is_value_valid (s)
		ensure
			date_time_exists: Result /= Void
			day_text_equal_day: right_day_text

	create_date (s: STRING_8): DATE
			-- Create a DATE according to the format in s.
		require
			s_exists: s /= Void
			is_precise: precise_date
			s_correspond: correspond (s)
		ensure
			date_exists: Result /= Void
			day_text_equal_day: right_day_text

	create_time (s: STRING_8): TIME
			-- Create a TIME according to the format in s.
		require
			s_exists: s /= Void
			is_precise: precise_time
			s_correspond: correspond (s)
		ensure
			time_exists: Result /= Void
			time_correspond: create_time_string (Result).same_string (s)

	precise: BOOLEAN
			-- Is the code string enough precise to create
			-- nn instance of type DATE_TIME?
		require
			not_void: value /= Void

	precise_date: BOOLEAN
			-- Is the code string enough precise to create
			-- nn instance of type DATE?
		require
			not_void: value /= Void

	precise_time: BOOLEAN
			-- Is the code string enough precise to create
			-- an instance of type TIME?
		require
			not_void: value /= Void
	
note
	copyright: "Copyright (c) 1984-2018, 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_STRING

Generated by ISE EiffelStudio