fn at_time_zone<T>(self, timezone: T) -> dsl::AtTimeZone<Self, T>
    where
        T: AsExpression<VarChar>,
    {
        Grouped(AtTimeZone::new(self, timezone.as_expression()))
    }
/// Creates a PostgreSQL "AT TIME ZONE" expression.
///
/// When this is called on a `TIMESTAMP WITHOUT TIME ZONE` column,
/// the value will be treated as if were in the given time zone,
/// and then converted to UTC.
///
/// When this is called on a `TIMESTAMP WITH TIME ZONE` column,
/// the value will be converted to the given time zone,
/// and then have its time zone information removed.
///
/// # Example
///
/// ```rust
/// # include!("../../doctest_setup.rs");
/// #
/// # table! {
/// #     timestamps (timestamp) {
/// #         timestamp -> Timestamp,
/// #     }
/// # }
/// #
/// # fn main() {
/// #     run_test().unwrap();
/// # }
/// #
/// # #[cfg(all(feature = "postgres", feature = "chrono"))]
/// # fn run_test() -> QueryResult<()> {
/// #     use self::timestamps::dsl::*;
/// #     use chrono::*;
/// #     let connection = &mut establish_connection();
/// #     connection.execute("CREATE TABLE timestamps (\"timestamp\"
/// #         timestamp NOT NULL)")?;
/// let christmas_morning = NaiveDate::from_ymd(2017, 12, 25)
///     .and_hms(8, 0, 0);
/// diesel::insert_into(timestamps)
///     .values(timestamp.eq(christmas_morning))
///     .execute(connection)?;
///
/// let utc_time = timestamps
///     .select(timestamp.at_time_zone("UTC"))
///     .first(connection)?;
/// assert_eq!(christmas_morning, utc_time);
///
/// let eastern_time = timestamps
///     .select(timestamp.at_time_zone("EST"))
///     .first(connection)?;
/// let five_hours_later = christmas_morning + Duration::hours(5);
/// assert_eq!(five_hours_later, eastern_time);
/// #     Ok(())
/// # }
/// #
/// # #[cfg(not(all(feature = "postgres", feature = "chrono")))]
/// # fn run_test() -> QueryResult<()> {
/// #     Ok(())
/// # }
/// ```
Creates a PostgreSQL "AT TIME ZONE" expression.
When this is called on a `TIMESTAMP WITHOUT TIME ZONE` column,
the value will be treated as if were in the given time zone,
and then converted to UTC.

When this is called on a `TIMESTAMP WITH TIME ZONE` column,
the value will be converted to the given time zone,
and then have its time zone information removed.
Creates a PostgreSQL " AT TIME ZONE " expression . When this is called on a ` TIMESTAMP WITHOUT TIME ZONE ` column the value will be treated as if were in the given time zone and then converted to UTC . When this is called on a ` TIMESTAMP WITH TIME ZONE ` column the value will be converted to the given time zone and then have its time zone information removed .
fn at_time_zone<T>(self, timezone: T) -> dsl::AtTimeZone<Self, T>
    where
        T: AsExpression<VarChar>,
    {
        Grouped(AtTimeZone::new(self, timezone.as_expression()))
    }
fn at_time_zone < T > ( self , timezone : T ) -> dsl :: AtTimeZone < Self , T > where T : AsExpression < VarChar > , { Grouped ( AtTimeZone :: new ( self , timezone . as_expression ( ) ) ) }
Creates a PostgreSQL "AT TIME ZONE" expression.
Creates a PostgreSQL " AT TIME ZONE " expression .
self
timezone
T
self
timezone
T
example
None
include!("../../doctest_setup.rs");
None
table! {
None
timestamps (timestamp) {
None
timestamp -> timestamp,
None
}
None
}
None
fn main() {
None
run_test().unwrap();
None
}
None
#[cfg(all(feature = "postgres", feature = "chrono"))]
None
fn run_test() -> queryresult<()> {
None
use self::timestamps::dsl::*;
None
use chrono::*;
None
let connection = &mut establish_connection();
None
connection.execute("create table timestamps (\"timestamp\"
None
timestamp not null)")?;
let christmas_morning = NaiveDate::from_ymd(2017, 12, 25)
.and_hms(8, 0, 0);
diesel::insert_into(timestamps)
.values(timestamp.eq(christmas_morning))
.execute(connection)?.

let utc_time = timestamps
.select(timestamp.at_time_zone("UTC"))
.first(connection)?;
assert_eq!(christmas_morning, utc_time).

let eastern_time = timestamps
.select(timestamp.at_time_zone("EST"))
.first(connection)?;
let five_hours_later = christmas_morning + Duration::hours(5);
assert_eq!(five_hours_later, eastern_time).
let christmas_morning = NaiveDate :: from_ymd ( 2017 12 25 ) . and_hms ( 8 0 0 ) ; diesel :: insert_into ( timestamps ) . values ( timestamp . eq ( christmas_morning )) . execute ( connection ) ? . let utc_time = timestamps . select ( timestamp . at_time_zone ( " UTC " )) . first ( connection ) ? ; assert_eq! ( christmas_morning utc_time ) . let eastern_time = timestamps . select ( timestamp . at_time_zone ( " EST " )) . first ( connection ) ? ; let five_hours_later = christmas_morning + Duration :: hours ( 5 ) ; assert_eq! ( five_hours_later eastern_time ) .
ok(())
None
}
None
#[cfg(not(all(feature = "postgres", feature = "chrono")))]
None
fn run_test() -> queryresult<()> {
None
ok(())
None
}
None