@@ -5,14 +5,14 @@ use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
5
5
use self :: chrono:: { Duration , NaiveDate , NaiveTime , NaiveDateTime , DateTime , UTC } ;
6
6
7
7
use Result ;
8
- use types:: { FromSql , ToSql , IsNull , Type } ;
8
+ use types:: { FromSql , ToSql , IsNull , Type , SessionInfo } ;
9
9
10
10
fn base ( ) -> NaiveDateTime {
11
11
NaiveDate :: from_ymd ( 2000 , 1 , 1 ) . and_hms ( 0 , 0 , 0 )
12
12
}
13
13
14
14
impl FromSql for NaiveDateTime {
15
- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveDateTime > {
15
+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveDateTime > {
16
16
let t = try!( raw. read_i64 :: < BigEndian > ( ) ) ;
17
17
Ok ( base ( ) + Duration :: microseconds ( t) )
18
18
}
@@ -21,7 +21,7 @@ impl FromSql for NaiveDateTime {
21
21
}
22
22
23
23
impl ToSql for NaiveDateTime {
24
- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
24
+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
25
25
let t = ( * self - base ( ) ) . num_microseconds ( ) . unwrap ( ) ;
26
26
try!( w. write_i64 :: < BigEndian > ( t) ) ;
27
27
Ok ( IsNull :: No )
@@ -32,7 +32,7 @@ impl ToSql for NaiveDateTime {
32
32
}
33
33
34
34
impl FromSql for DateTime < UTC > {
35
- fn from_sql < R : Read > ( type_ : & Type , raw : & mut R ) -> Result < DateTime < UTC > > {
35
+ fn from_sql < R : Read > ( type_ : & Type , raw : & mut R , _ : & SessionInfo ) -> Result < DateTime < UTC > > {
36
36
let naive = try!( NaiveDateTime :: from_sql ( type_, raw) ) ;
37
37
Ok ( DateTime :: from_utc ( naive, UTC ) )
38
38
}
@@ -41,7 +41,8 @@ impl FromSql for DateTime<UTC> {
41
41
}
42
42
43
43
impl ToSql for DateTime < UTC > {
44
- fn to_sql < W : Write +?Sized > ( & self , type_ : & Type , mut w : & mut W ) -> Result < IsNull > {
44
+ fn to_sql < W : Write +?Sized > ( & self , type_ : & Type , mut w : & mut W , _: & SessionInfo )
45
+ -> Result < IsNull > {
45
46
self . naive_utc ( ) . to_sql ( type_, w)
46
47
}
47
48
@@ -50,7 +51,7 @@ impl ToSql for DateTime<UTC> {
50
51
}
51
52
52
53
impl FromSql for NaiveDate {
53
- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveDate > {
54
+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveDate > {
54
55
let jd = try!( raw. read_i32 :: < BigEndian > ( ) ) ;
55
56
Ok ( base ( ) . date ( ) + Duration :: days ( jd as i64 ) )
56
57
}
@@ -59,7 +60,7 @@ impl FromSql for NaiveDate {
59
60
}
60
61
61
62
impl ToSql for NaiveDate {
62
- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
63
+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
63
64
let jd = * self - base ( ) . date ( ) ;
64
65
try!( w. write_i32 :: < BigEndian > ( jd. num_days ( ) as i32 ) ) ;
65
66
Ok ( IsNull :: No )
@@ -70,7 +71,7 @@ impl ToSql for NaiveDate {
70
71
}
71
72
72
73
impl FromSql for NaiveTime {
73
- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveTime > {
74
+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveTime > {
74
75
let usec = try!( raw. read_i64 :: < BigEndian > ( ) ) ;
75
76
Ok ( NaiveTime :: from_hms ( 0 , 0 , 0 ) + Duration :: microseconds ( usec) )
76
77
}
@@ -79,7 +80,7 @@ impl FromSql for NaiveTime {
79
80
}
80
81
81
82
impl ToSql for NaiveTime {
82
- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
83
+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
83
84
let delta = * self - NaiveTime :: from_hms ( 0 , 0 , 0 ) ;
84
85
try!( w. write_i64 :: < BigEndian > ( delta. num_microseconds ( ) . unwrap ( ) ) ) ;
85
86
Ok ( IsNull :: No )
0 commit comments