DBIx::...:Epoch(3pm)
π DBIx::...:Epoch π
okay so bestie, gather round, because this is a page from the User Contributed Perl Documentation and it's literally about the module DBIx::Class::DateTime::Epoch π
she's a lil gem and we're gonna go through her together, no skipping, no skimming, we do this right π«Ά
β¨ NAME β¨
DBIx::Class::DateTime::Epoch β Automatic inflation/deflation of epoch-based columns to/from DateTime objects πΈ
like. it takes your boring raw epoch numbers and turns them into gorgeous DateTime objects and then puts them back. that's the whole vibe. and it does it automatically, which is the slay part π
π SYNOPSIS π
package MySchema::Foo;
use base qw( DBIx::Class );
__PACKAGE__->load_components( qw( DateTime::Epoch TimeStamp Core ) );
__PACKAGE__->add_columns(
name => {
data_type => 'varchar',
size => 10,
},
bar => { # epoch stored as an int
data_type => 'bigint',
inflate_datetime => 1,
},
baz => { # epoch stored as a string
data_type => 'varchar',
size => 50,
inflate_datetime => 'epoch',
},
# working in conjunction with DBIx::Class::TimeStamp
creation_time => {
data_type => 'bigint',
inflate_datetime => 1,
set_on_create => 1,
},
modification_time => {
data_type => 'bigint',
inflate_datetime => 1,
set_on_create => 1,
set_on_update => 1,
}
);
see how bar is an int and baz is a varchar? both of them get the inflate_datetime treatment, they just get there different ways π and then creation_time and modification_time are out here working in conjunction with DBIx::Class::TimeStamp, living their best lives, setting themselves on create and update πβ¨
π¦ DATETIME::FORMAT DEPENDENCY π¦
not me having to be the responsible one for a sec: no assumptions have been made about which RDBMS you're using π
so, as per the note over in the DBIx::Class::InflateColumn::DateTime documentation β yes, go read her, she's the parent here β you will need to install the DateTime::Format::* module that matches your RDBMS of choice. like, the one that goes with your database. that one. install it. periodt π
πΈ DESCRIPTION πΈ
This module automatically inflates/deflates DateTime objects from/to epoch values for the columns you specify β¨ She is, at her core, an extension to DBIx::Class::InflateColumn::DateTime, so all of those settings β including "locale" and "timezone" β are also valid here. everything she can do, this one can do too. nepotism but make it useful π
A column gets recognized as an epoch time given one of the following scenarios:
"data_type"is an"int"of some sort and"inflate_datetime"is also set to a true value π"data_type"is some other value (e.g."varchar") and"inflate_datetime"is explicitly set to"epoch"π
and DBIx::Class::TimeStamp can also be used in conjunction with this module to support epoch-based columns that are automatically set on creation of a row and updated on subsequent modifications π like a little timestamp fairy that never forgets π§
π METHODS π
add_columns( )
Provides backwards compatibility with the older DateTime::Epoch API. she remembers her roots π
_inflate_to_datetime( )
Overrides column inflation to use Datetime->from_epoch. yes, that's Datetime with a lowercase s in there, bestie, we copy exactly what's written, no cap π
_deflate_from_datetime( )
Overrides column deflation to call epoch() on the column value. so it goes back to being a number. she contains multitudes π₯
β SEE ALSO β
DBIx::ClassDBIx::Class::TimeStampDateTime
iykyk, these three are the whole friend group π
π AUTHORS π
- Brian Cassidy <bricas@cpan.org>
- Adam Paynter <adapay@cpan.org>
two icons. we stan. π
π COPYRIGHT AND LICENSE π
Copyright 2006-2012 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
(that's the legal bit, and yes it's giving very official, but it's important so we keep it word for word π )
okay that's the whole page!! and for the lil sign-off moment: this lovely thing is documented in perl v5.34.0, dated 2022-06-13, and the manual page lives under the name DBIx::...:Epoch(3pm) π¦β¨ go inflate something, bestie π
π¦ where this page comes from
- debian bookworm: libdbix-class-datetime-epoch-perl 0.10-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdbix-class-datetime-epoch-perl 0.10-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdbix-class-datetime-epoch-perl 0.10-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-datetime-epoch-perl 0.10-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-datetime-epoch-perl 0.10-2 Β· 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