-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support RFC 3339 timestamp values in sql
- Loading branch information
1 parent
5159c79
commit 8820a65
Showing
6 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use anyhow::Context; | ||
use chrono::DateTime; | ||
use spacetimedb_sats::timestamp::Timestamp; | ||
|
||
/// Parses an RFC 3339 formated timestamp string | ||
pub fn parse_timestamp_from_str(str: &str) -> anyhow::Result<Timestamp> { | ||
DateTime::parse_from_rfc3339(str) | ||
.map_err(|err| anyhow::anyhow!(err)) | ||
.with_context(|| "Invalid timestamp format. Expected RFC 3339 format (e.g. '2025-02-10 15:45:30').") | ||
.map(|dt| dt.timestamp_micros()) | ||
.map(Timestamp::from_micros_since_unix_epoch) | ||
} |