NAME
DBIO::Storage::DateTimeFormat - Strptime-backed datetime format base for driver format classes
VERSION
version 0.900000
SYNOPSIS
package DBIO::DriverName::DateTime::Format;
# ABSTRACT: DateTime parsing for DriverName
use base 'DBIO::Storage::DateTimeFormat';
__PACKAGE__->preferred_format_class('DateTime::Format::DriverName'); # optional
__PACKAGE__->datetime_parse_pattern('%Y-%m-%d %H:%M:%S.%3N');
__PACKAGE__->datetime_format_pattern('%Y-%m-%d %H:%M:%S.%3N');
__PACKAGE__->date_parse_pattern('%Y-%m-%d'); # optional, enables parse_date
__PACKAGE__->date_format_pattern('%Y-%m-%d');
1;
Then point the storage at it:
__PACKAGE__->datetime_parser_type('DBIO::DriverName::DateTime::Format');
DESCRIPTION
Base class for driver datetime format classes where no (maintained) CPAN DateTime::Format::* module exists. Subclasses declare strptime patterns as class data and may name a preferred CPAN format class: when that class is installed it handles all calls, otherwise the declared patterns are used via DateTime::Format::Strptime.
Patterns are read once per class and the resulting parser objects are cached — set the class data at load time, not dynamically.
ATTRIBUTES
preferred_format_class
Optional name of a CPAN format class (e.g. DateTime::Format::Sybase). Delegated to when loadable; declare it as suggests in the driver cpanfile. The fallback patterns MUST round-trip identically to the preferred class.
datetime_parse_pattern
datetime_format_pattern
Strptime patterns backing "parse_datetime" and "format_datetime".
date_parse_pattern
date_format_pattern
Optional strptime patterns backing "parse_date" and "format_date".
METHODS
parse_datetime
my $dt = $class->parse_datetime($string);
Parses a datetime string from the database into a DateTime object, via the preferred format class when loadable, otherwise via datetime_parse_pattern.
format_datetime
my $string = $class->format_datetime($dt);
Formats a DateTime object for the database, via the preferred format class when loadable, otherwise via datetime_format_pattern.
parse_date
my $dt = $class->parse_date($string);
Like "parse_datetime" for plain dates. Delegates to the preferred format class only when it implements parse_date; otherwise requires date_parse_pattern to be set.
format_date
my $string = $class->format_date($dt);
Like "format_datetime" for plain dates. Delegates to the preferred format class only when it implements format_date; otherwise requires date_format_pattern to be set.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.