Skip to content

Commit

Permalink
Use std::time instead of time crate in public API
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed May 27, 2023
1 parent 9cd2647 commit 7560b45
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/api/autogen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function handleType(
kind: 'Date',
format: (schema as any)['date-format']
}));
return rusty('time::OffsetDateTime', `${formatter}`);
return rusty('std::time::SystemTime', `${formatter}`);
}
return rusty('String');
case 'boolean':
Expand Down Expand Up @@ -763,16 +763,16 @@ ${stringifyIter(types, ({ features, type }) => {
}
${cfg}
impl From<time::OffsetDateTime> for ${type.name} {
fn from(value: time::OffsetDateTime) -> Self {
Self { value }
impl From<std::time::SystemTime> for ${type.name} {
fn from(value: std::time::SystemTime) -> Self {
Self { value: value.into() }
}
}
${cfg}
impl From<${type.name}> for time::OffsetDateTime {
impl From<${type.name}> for std::time::SystemTime {
fn from(wrapper: ${type.name}) -> Self {
wrapper.value
wrapper.value.into()
}
}
Expand Down
30 changes: 17 additions & 13 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,18 @@ pub(crate) struct LastExposureStartTime {
}

#[cfg(feature = "camera")]
impl From<time::OffsetDateTime> for LastExposureStartTime {
fn from(value: time::OffsetDateTime) -> Self {
Self { value }
impl From<std::time::SystemTime> for LastExposureStartTime {
fn from(value: std::time::SystemTime) -> Self {
Self {
value: value.into(),
}
}
}

#[cfg(feature = "camera")]
impl From<LastExposureStartTime> for time::OffsetDateTime {
impl From<LastExposureStartTime> for std::time::SystemTime {
fn from(wrapper: LastExposureStartTime) -> Self {
wrapper.value
wrapper.value.into()
}
}

Expand Down Expand Up @@ -443,16 +445,18 @@ pub(crate) struct TelescopeUtcdate {
}

#[cfg(feature = "telescope")]
impl From<time::OffsetDateTime> for TelescopeUtcdate {
fn from(value: time::OffsetDateTime) -> Self {
Self { value }
impl From<std::time::SystemTime> for TelescopeUtcdate {
fn from(value: std::time::SystemTime) -> Self {
Self {
value: value.into(),
}
}
}

#[cfg(feature = "telescope")]
impl From<TelescopeUtcdate> for time::OffsetDateTime {
impl From<TelescopeUtcdate> for std::time::SystemTime {
fn from(wrapper: TelescopeUtcdate) -> Self {
wrapper.value
wrapper.value.into()
}
}

Expand Down Expand Up @@ -963,7 +967,7 @@ pub trait Camera: Device + Send + Sync {

/// Reports the actual exposure start in the FITS-standard CCYY-MM-DDThh:mm:ss[.sss...] format.
#[http("lastexposurestarttime", method = Get, via = LastExposureStartTime)]
async fn last_exposure_start_time(&self) -> ASCOMResult<time::OffsetDateTime> {
async fn last_exposure_start_time(&self) -> ASCOMResult<std::time::SystemTime> {
Err(ASCOMError::NOT_IMPLEMENTED)
}

Expand Down Expand Up @@ -2230,7 +2234,7 @@ pub trait Telescope: Device + Send + Sync {

/// Returns the UTC date/time of the telescope's internal clock.
#[http("utcdate", method = Get, via = TelescopeUtcdate)]
async fn utc_date(&self) -> ASCOMResult<time::OffsetDateTime> {
async fn utc_date(&self) -> ASCOMResult<std::time::SystemTime> {
Err(ASCOMError::NOT_IMPLEMENTED)
}

Expand All @@ -2239,7 +2243,7 @@ pub trait Telescope: Device + Send + Sync {
async fn set_utc_date(
&self,

#[http("UTCDate", via = TelescopeUtcdate)] utc_date: time::OffsetDateTime,
#[http("UTCDate", via = TelescopeUtcdate)] utc_date: std::time::SystemTime,
) -> ASCOMResult {
Err(ASCOMError::NOT_IMPLEMENTED)
}
Expand Down

0 comments on commit 7560b45

Please sign in to comment.