tag = 'DTM' Eancom.register_segment(tag: tag, klass: Eancom::Edifact::DTM) structure = Eancom::Edifact::Structure.new(tag: tag) composite = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 3, description: "DATE/TIME/PERIOD", required: true ) composite.add(:tag, data) structure << composite composite = Eancom::Edifact::Composite.new() type_dictionary = { '1' => { description: 'Service completion date/time, actual', identifier: 'service_completion_date_time_actual' }, '2' => { description: 'Delivery date/time, reqested', identifier: 'delivery_date_time' }, '7' => { description: 'Effectiv date/time', identifier: 'effectiv_date_time' }, '11' => { description: 'Despatch date and/or time', identifier: 'despatch_date_and_or_time' }, '17' => { description: 'Delivery date/time, estimated', identifier: 'delivery_date_time_estimated' }, '35' => { description: 'Delivery date and/or time', identifier: 'delivery_date_and_or_time' }, '36' => { description: 'Expiry Date', identifier: 'expiry_date' }, '44' => { description: 'Availability', identifier: 'availability' }, '50' => { description: 'Goods receipt date/time', identifier: 'goods_receipt_date_time' }, '63' => { description: 'Delivery date/time, latest', identifier: 'delivery_date_time_latest' }, '90' => { description: 'Report start date', identifier: 'report_start_date' }, '91' => { description: 'Report end date', identifier: 'report_end_date' }, '64' => { description: 'Delivery date/time, earliest', identifier: 'delivery_date_time_earliest' }, '137' => { description: 'Document/message date/time', identifier: 'document_message_date_time' }, '157' => { description: 'Validity start date', identifier: 'valitity_start_date' }, '171' => { description: 'Reference date/time', identifier: 'reference_date_time' }, '194' => { description: 'Start date/time', identifier: 'start_date_time' }, '200' => { description: 'Pick-up/collection date/time of cargo', identifier: 'pick_up_collection_date_time_of_cargo' }, '206' => { description: 'End date/time', identifier: 'end_date_time' }, '263' => { description: 'Invoicing period', identifier: 'invoicing_period' }, '325' => { description: 'Tax period', identifier: 'tax_period' }, '356' => { description: 'Sales date, and or time, and or period', identifier: 'sales_date_and_or_time_and_or_period' }, '418' => { description: 'Minimum shelf life remaining at time of receipt', identifier: 'minimum_shelf_life_remaining_at_time_of_receipt' }, '423' => { description: 'First date of ordering', identifier: 'first_date_of_ordering' }, '454' => { description: 'Accounting value date', identifier: 'accounting_value_date' }, '44E' => { description: 'Connection date/time', identifier: 'connection_date_time' }, '765' => { description: 'Seasonal availabilty calendar year', identifier: 'seasonal_availabilty_calendar_year' } } data = Eancom::Edifact::Data.new( type: String, length: 1..3, dictionary: type_dictionary, description: 'Date or time or period function code qualifier', required: true ) composite.add(:type, data) data = Eancom::Edifact::Data.new( type: String, length: 1..35, description: 'Date or time or period value', required: true ) composite.add(:date_time, data) format_dictionary = { '102' => { description: 'Date', value: 'CCYYMMDD', identifier: 'date' }, '203' => { description: 'Date and Time', value: 'CCYYMMDDHHMM', identifier: 'date_time' }, '204' => { description: 'Date and Time', value: 'CCYYMMDDHHMMSS', identifier: 'date_time_second' }, '602' => { description: 'Calendar year including century: C = Century; Y = Year', value: 'CCYY', identifier: 'century_year' }, '718' => { description: 'Period', value: 'CCYYMMDD-CCZZMMDD', identifier: 'period' }, '801' => { description: 'Year', identifier: 'year' } } data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: format_dictionary, description: 'Date or time or period value', required: true ) composite.add(:format, data) structure << composite Eancom.register_structure(tag: 'DTM', structure: structure)