File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1+ use pg_interval:: PgInterval ;
2+
3+ impl PgInterval {
4+ pub fn from_iso < T : Into < String > > ( iso_str : T ) -> PgInterval {
5+ lazy_static ! {
6+ static ref RE : Regex = Regex :: new( "P(?:(\d +?Y)?(\d +?M)?(\d +?D)?(?:T(\d +?H)?(\d +?M)?(\d +(?:[\. ,]\d {0,6})?S)?)?)$" ) . unwrap( ) ;
7+ }
8+ for interval in RE . captures_iter ( iso_str. into ( ) ) {
9+ let year = caps. get ( 1 ) . unwrap_or ( "0" ) . as_str ( ) ;
10+ let month = caps. get ( 2 ) . unwrap_or ( "0" ) . as_str ( ) ;
11+ let day = caps. get ( 3 ) . unwrap_or ( "0" ) . as_str ( ) ;
12+ let hours = caps. get ( 4 ) . unwrap_or ( "0" ) . as_str ( ) ;
13+ let minutes = caps. get ( 5 ) . unwrap_or ( "0" ) . as_str ( ) ;
14+ let seconds = caps. get ( 6 ) . unwrap_or ( "0.0" ) . as_str ( ) ;
15+
16+ }
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ mod iso_8601;
You can’t perform that action at this time.
0 commit comments