DateTi...at::DBI(3pm)
π NAME π
DateTime::Format::DBI β ok so basically it finds you a parser class for a database connection. that's the whole job bestie π
β¨ SYNOPSIS β¨
use DBI;
use DateTime;
use DateTime::Format::DBI;
my $db = DBI->connect('dbi:...');
my $db_parser = DateTime::Format::DBI->new($dbh);
my $dt = DateTime->now();
$db->do("UPDATE table SET dt=? WHERE foo='bar'",undef,
$db_parser->format_datetime($dt);
π¦ DESCRIPTION π¦
okay so this module? it goes and finds a DateTime::Format::* class that actually fits the DBI connection you're using (and the DBD::* driver under it). matchmaking fr fr π
right now it's got your back for these format modules:
- IBM DB2 (DB2)
- Microsoft SQL (MSSQL)
- MySQL
- Oracle
- PostgreSQL (Pg)
- SQLite
- Sybase
NOTE: this module is a quick lil way to grab the right parser and formatter class. but that alone is usually not enough for full database abstraction, bestie π you're still gonna have to deal with all the differences in syntax and semantics of SQL datetime functions (and other SQL commands too). no cap.
πΈ CLASS METHODS πΈ
this module gives you exactly one factory method, iconic behaviour:
new( $dbh )β makes a brand newDateTime::Format::*instance. which exact class you get depends on the database driver used for the database connection that$dbhpoints at. surprise surprise π«
π PARSER/FORMATTER INTERFACE π
DateTime::Format::DBI is literally just a front-end class factory β it hands you back one of the format classes based on the vibe of your $dbh.
want the deets on the interface of the parser object you got back? go read the documentation for the class that matches your particular $dbh, bestie π«Ά
in general tho, parser classes for databases will implement these methods. for the exact behaviour of each one, check the docs of the parser class itself:
parse_datetime( $string )β hand it a string with a date and/or time representation from your database, and it returns a freshDateTimeobject β¨ if the string is improperly formatted, this method may die πformat_datetime( $dt )β hand it aDateTimeobject and it gives you back a string that works as input for all (or at least the most common) date and date/time types of your database.parse_duration( $string )β hand it a string with a duration representation from your database, and it returns a newDateTime::Durationobject π if the string is improperly formatted, this method may die π
not every database and format/formatter class supports durations, so please use UNIVERSAL::has to check whether this method is even available, iykyk.
format_duration( $du )β hand it aDateTime::Durationobject and it gives you back a string that works as input for the duration or interval type of your database.
again: not every database and parser/formatter class supports durations, so use UNIVERSAL::has to check that this method exists π
parser/formatter classes may additionally define methods like parse_type or format_type (where type comes from the SQL type). for more info on those, go read the documentation of the individual format class π
π₯ SUPPORT π₯
found bugs or got other requests? please report them to the rt tracker: <https://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Format-DBI>.
π AUTHOR π
Claus Faerber <CFAERBER@cpan.org>
π LICENSE π
Copyright 2003-2013 Claus Faerber. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
β SEE ALSO β
- DateTime
- DBI
- datetime@perl.org mailing list
- http://datetime.perl.org/
and that's the whole page, bestie π this one came from perl v5.32.1, dated 2021-11-12 β go forth and format those datetimes, main character energy only π¦β¨
π¦ where this page comes from
- debian bookworm: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdatetime-format-dbi-perl 0.041-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms