Skip to content

Commit

Permalink
Convert string_to_timestamp_nanos to doctest (#3978)
Browse files Browse the repository at this point in the history
* Convert string_to_timestamp_nanos to doctest

* Update arrow-cast/src/parse.rs

Co-authored-by: Andrew Lamb <[email protected]>

---------

Co-authored-by: Andrew Lamb <[email protected]>
  • Loading branch information
tustvold and alamb authored Mar 30, 2023
1 parent cf7f7c0 commit 20522a8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions arrow-cast/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,18 @@ pub fn string_to_datetime<T: TimeZone>(
/// This function interprets string without an explicit time zone as timestamps
/// relative to UTC, see [`string_to_datetime`] for alternative semantics
///
/// For example, both `1997-01-31 09:26:56.123Z`, `1997-01-31T09:26:56.123`,
/// and `1997-01-31T14:26:56.123+05:00` will be parsed as the same value
/// In particular:
///
/// ```
/// # use arrow_cast::parse::string_to_timestamp_nanos;
/// // Note all three of these timestamps are parsed as the same value
/// let a = string_to_timestamp_nanos("1997-01-31 09:26:56.123Z").unwrap();
/// let b = string_to_timestamp_nanos("1997-01-31T09:26:56.123").unwrap();
/// let c = string_to_timestamp_nanos("1997-01-31T14:26:56.123+05:00").unwrap();
///
/// assert_eq!(a, b);
/// assert_eq!(b, c);
/// ```
///
#[inline]
pub fn string_to_timestamp_nanos(s: &str) -> Result<i64, ArrowError> {
Expand Down

0 comments on commit 20522a8

Please sign in to comment.