| 1 | package DBIO::MSSQL::Storage::DateTime::Format; | ||
| 2 | # ABSTRACT: DateTime parser for MSSQL datetime and smalldatetime columns | ||
| 3 | |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = '0.900004'; | |
| 8 | |||
| 9 | 2 | ▶ | use base 'DBIO::Storage::DateTimeFormat'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | # MSSQL adds a third channel beyond the base datetime/date: smalldatetime | ||
| 12 | # (minute precision, no fractional seconds). Core's InflateColumn::DateTime | ||
| 13 | # routes it to parse_smalldatetime/format_smalldatetime when the parser | ||
| 14 | # ->can() them, otherwise falls back to parse_datetime/format_datetime. | ||
| 15 | 2 | __PACKAGE__->mk_group_accessors('inherited' => qw/ | |
| 16 | smalldatetime_parse_pattern smalldatetime_format_pattern | ||
| 17 | /); | ||
| 18 | |||
| 19 | 2 | __PACKAGE__->datetime_parse_pattern('%Y-%m-%d %H:%M:%S.%3N'); # %F %T | |
| 20 | 2 | __PACKAGE__->datetime_format_pattern('%Y-%m-%d %H:%M:%S.%3N'); | |
| 21 | 2 | __PACKAGE__->smalldatetime_parse_pattern('%Y-%m-%d %H:%M:%S'); | |
| 22 | 2 | __PACKAGE__->smalldatetime_format_pattern('%Y-%m-%d %H:%M:%S'); | |
| 23 | |||
| 24 | |||
| 25 | 1 | ▶ | sub parse_smalldatetime { |
|
Subroutine
parse_smalldatetime: called CC=1 SCAR=0.0
Pod
documented
| |||
| 26 | 1 | my ($class, $value) = @_; | |
| 27 | |||
| 28 | 1 | return $class->_strptime_for(smalldatetime_parse => 'smalldatetime_parse_pattern') | |
| 29 | ->parse_datetime($value); | ||
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | 1 | ▶ | sub format_smalldatetime { |
|
Subroutine
format_smalldatetime: called CC=1 SCAR=0.0
Pod
documented
| |||
| 34 | 1 | my ($class, $dt) = @_; | |
| 35 | |||
| 36 | 1 | return $class->_strptime_for(smalldatetime_format => 'smalldatetime_format_pattern') | |
| 37 | ->format_datetime($dt); | ||
| 38 | } | ||
| 39 | |||
| 40 | 2 | 1; | |
| 41 | |||
| 42 | __END__ | ||