MCPcopy Create free account
hub / github.com/TankHQ/tank / write_timestamp

Method write_timestamp

tank-postgres/src/sql_writer.rs:147–168  ·  view source on GitHub ↗
(
        &self,
        context: &mut Context,
        out: &mut DynQuery,
        value: &PrimitiveDateTime,
    )

Source from the content-addressed store, hash-verified

145 }
146
147 fn write_timestamp(
148 &self,
149 context: &mut Context,
150 out: &mut DynQuery,
151 value: &PrimitiveDateTime,
152 ) {
153 let is_timestamp = context.fragment == Fragment::Timestamp;
154 let (l, r) = match context.fragment {
155 Fragment::None | Fragment::ParameterBinding | Fragment::Timestamp => ("", ""),
156 Fragment::Json | Fragment::JsonKey => ("\"", "\""),
157 _ => ("'", "'::TIMESTAMP"),
158 };
159 let mut context = context.switch_fragment(Fragment::Timestamp);
160 out.push_str(l);
161 self.write_date(&mut context.current, out, &value.date());
162 out.push('T');
163 self.write_time(&mut context.current, out, &value.time());
164 if !is_timestamp && value.date().year() <= 0 {
165 out.push_str(" BC");
166 }
167 out.push_str(r);
168 }
169
170 fn write_timestamptz(&self, context: &mut Context, out: &mut DynQuery, value: &OffsetDateTime) {
171 let (l, r) = match context.fragment {

Callers 1

write_timestamptzMethod · 0.45

Calls 5

switch_fragmentMethod · 0.80
push_strMethod · 0.80
pushMethod · 0.80
write_dateMethod · 0.45
write_timeMethod · 0.45

Tested by

no test coverage detected