Skip to main content

ifc_constraint/
datetime.rs

1//! Date and time inputs for authoring drafts, in the form each release
2//! declares.
3
4use ifc_model::EntityId;
5
6/// A date and time for an authoring draft, in the form the release
7/// declares it.
8///
9/// IFC4 and IFC4X3 declare `IfcDateTime`, ISO 8601 text written as given;
10/// IFC2X3 declares `IfcDateTimeSelect`, a reference to an existing or
11/// earlier-staged `IfcCalendarDate`, `IfcLocalTime` or `IfcDateAndTime`.
12/// A form the release does not declare is refused.
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14#[non_exhaustive]
15pub enum DateTimeInput<'a> {
16    /// IFC4/IFC4X3 `IfcDateTime` text.
17    Text(&'a str),
18    /// An IFC2X3 `IfcDateTimeSelect` record.
19    Record(EntityId),
20}
21
22impl<'a> From<&'a str> for DateTimeInput<'a> {
23    fn from(text: &'a str) -> Self {
24        Self::Text(text)
25    }
26}
27
28impl From<EntityId> for DateTimeInput<'_> {
29    fn from(record: EntityId) -> Self {
30        Self::Record(record)
31    }
32}