1DBIx::Class::DateTime::UEspeorchC(o3n)tributed Perl DocuDmBeInxt:a:tCiloanss::DateTime::Epoch(3)
2
3
4

NAME

6       DBIx::Class::DateTime::Epoch - Automatic inflation/deflation of
7       epoch-based columns to/from DateTime objects
8

SYNOPSIS

10           package MySchema::Foo;
11
12           use base qw( DBIx::Class );
13
14           __PACKAGE__->load_components( qw( DateTime::Epoch TimeStamp Core ) );
15           __PACKAGE__->add_columns(
16               name => {
17                   data_type => 'varchar',
18                   size      => 10,
19               },
20               bar => { # epoch stored as an int
21                   data_type        => 'bigint',
22                   inflate_datetime => 1,
23               },
24               baz => { # epoch stored as a string
25                   data_type        => 'varchar',
26                   size             => 50,
27                   inflate_datetime => 'epoch',
28               },
29               # working in conjunction with DBIx::Class::TimeStamp
30               creation_time => {
31                   data_type        => 'bigint',
32                   inflate_datetime => 1,
33                   set_on_create    => 1,
34               },
35               modification_time => {
36                   data_type        => 'bigint',
37                   inflate_datetime => 1,
38                   set_on_create    => 1,
39                   set_on_update    => 1,
40               }
41           );
42

DATETIME::FORMAT DEPENDENCY

44       There have been no assumptions made as to what RDBMS you will be using.
45       As per the note in the DBIx::Class::InflateColumn::DateTime
46       documentation, you will need to install the DateTime::Format::* module
47       that matches your RDBMS of choice.
48

DESCRIPTION

50       This module automatically inflates/deflates DateTime objects from/to
51       epoch values for the specified columns. This module is essentially an
52       extension to DBIx::Class::InflateColumn::DateTime so all of the
53       settings, including "locale" and "timezone", are also valid.
54
55       A column will be recognized as an epoch time given one of the following
56       scenarios:
57
58       •   "data_type" is an "int" of some sort and "inflate_datetime" is also
59           set to a true value
60
61       •   "data_type" is some other value (e.g. "varchar") and
62           "inflate_datetime" is explicitly set to "epoch".
63
64       DBIx::Class::TimeStamp can also be used in conjunction with this module
65       to support epoch-based columns that are automatically set on creation
66       of a row and updated subsequent modifications.
67

METHODS

69   add_columns( )
70       Provides backwards compatibility with the older DateTime::Epoch API.
71
72   _inflate_to_datetime( )
73       Overrides column inflation to use "Datetime->from_epoch".
74
75   _deflate_from_datetime( )
76       Overrides column deflation to call epoch() on the column value.
77

SEE ALSO

79       •   DBIx::Class
80
81       •   DBIx::Class::TimeStamp
82
83       •   DateTime
84

AUTHORS

86       Brian Cassidy <bricas@cpan.org>
87
88       Adam Paynter <adapay@cpan.org>
89
91       Copyright 2006-2012 by Brian Cassidy
92
93       This library is free software; you can redistribute it and/or modify it
94       under the same terms as Perl itself.
95
96
97
98perl v5.38.0                      2023-07-20   DBIx::Class::DateTime::Epoch(3)
Impressum