Data Contract Specification v1.2.0

Time Data Type Example

Overview

This example demonstrates the usage of the new time data type introduced in Data Contract Specification v1.2.0. The time data type is specifically designed for storing time values without date information, making it perfect for business hours, schedules, and time-based data.

Note: The time data type may not be supported by all server types. Please check your specific data platform's documentation for compatibility.

Data Contract Details

Model: business_hours

This model demonstrates how to use the time data type for business hours and schedules.

location_id
type: string
Unique identifier for the business location
Examples:
"loc_001"
"loc_002"
opening_time
type: time
Daily opening time for the business
Examples:
"09:00:00"
"08:30:00"
closing_time
type: time
Daily closing time for the business
Examples:
"17:00:00"
"21:00:00"
lunch_start
type: time
Start time of lunch break
Examples:
"12:00:00"
"12:30:00"
lunch_end
type: time
End time of lunch break
Examples:
"13:00:00"
"13:30:00"

Model: shift_schedules

This model demonstrates time data type usage for employee shift schedules.

shift_start
type: time
Start time of the employee's shift
Examples:
"08:00:00"
"16:00:00"
shift_end
type: time
End time of the employee's shift
Examples:
"16:00:00"
"00:00:00"

Sample Data

Business Hours CSV Example:
location_id,location_name,opening_time,closing_time,lunch_start,lunch_end
"loc_001","Downtown Store","09:00:00","17:00:00","12:00:00","13:00:00"
"loc_002","Mall Branch","08:30:00","21:00:00","12:30:00","13:30:00"
"loc_003","24/7 Store","00:00:00","23:59:59",,
Shift Schedules CSV Example:
employee_id,shift_start,shift_end,break_start,break_end
"emp_001","08:00:00","16:00:00","12:00:00","13:00:00"
"emp_002","16:00:00","00:00:00","20:00:00","21:00:00"
"emp_003","00:00:00","08:00:00",,

Time Data Type Characteristics

Use Cases

Business Operations

Employee Management

Event Scheduling

Transportation

Comparison with Other Time-Related Types

Data Type Description Example
time Time only, no date "09:00:00"
date Date only, no time "2024-01-15"
timestamp Date and time with timezone "2024-01-15T09:00:00Z"

Testing

You can test this data contract using the Data Contract CLI:

datacontract test examples/time-example/datacontract.yaml
Important: When using the time data type, ensure your data processing tools and pipelines are compatible with time-only data. Some data platforms may require specific configurations or have limitations when working with time data types.