X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FFirebird%2FCommon.pm;h=6e61ca5cbb4e8935ac66b33488ea5f718d0cf361;hb=b8e92dac9f2f65895700dbd0d0606f75b900a8e0;hp=4676fc44d9640a705c672afae61aba6fe9a81e88;hpb=d77ee505c77d14a8a89cf356a014e7fbdc4e3967;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm index 4676fc4..6e61ca5 100644 --- a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm +++ b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm @@ -24,6 +24,14 @@ __PACKAGE__->_use_insert_returning (1); __PACKAGE__->sql_limit_dialect ('FirstSkip'); __PACKAGE__->sql_quote_char ('"'); +__PACKAGE__->datetime_parser_type( + 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format' +); + +sub sqlt_type { + return 'Firebird'; +} + sub _sequence_fetch { my ($self, $nextval, $sequence) = @_; @@ -108,7 +116,53 @@ SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') FROM rdb$database }); } -1; +package # hide from PAUSE + DBIx::Class::Storage::DBI::InterBase::DateTime::Format; + +my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T +my $date_format = '%Y-%m-%d'; + +my ($timestamp_parser, $date_parser); + +sub parse_datetime { + shift; + require DateTime::Format::Strptime; + $timestamp_parser ||= DateTime::Format::Strptime->new( + pattern => $timestamp_format, + on_error => 'croak', + ); + return $timestamp_parser->parse_datetime(shift); +} + +sub format_datetime { + shift; + require DateTime::Format::Strptime; + $timestamp_parser ||= DateTime::Format::Strptime->new( + pattern => $timestamp_format, + on_error => 'croak', + ); + return $timestamp_parser->format_datetime(shift); +} + +sub parse_date { + shift; + require DateTime::Format::Strptime; + $date_parser ||= DateTime::Format::Strptime->new( + pattern => $date_format, + on_error => 'croak', + ); + return $date_parser->parse_datetime(shift); +} + +sub format_date { + shift; + require DateTime::Format::Strptime; + $date_parser ||= DateTime::Format::Strptime->new( + pattern => $date_format, + on_error => 'croak', + ); + return $date_parser->format_datetime(shift); +} =head1 CAVEATS @@ -122,13 +176,19 @@ work with earlier versions. =back -=head1 AUTHOR +=head1 FURTHER QUESTIONS? -See L and L. +Check the list of L. -=head1 LICENSE +=head1 COPYRIGHT AND LICENSE -You may distribute this code under the same terms as Perl itself. +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. =cut + +1; + # vim:sts=2 sw=2: