Updated DB and added more DateTime
This commit is contained in:
parent
f9703b6561
commit
b44a256434
13 changed files with 1885 additions and 3 deletions
|
@ -148,7 +148,7 @@ sub post_upload {
|
|||
|
||||
my $transaction_value = $validation->param('transaction_value');
|
||||
my $upload = $validation->param('file');
|
||||
my $purchase_time = $validation->param('purchase_time');
|
||||
my $purchase_time = $c->parse_iso_datetime($validation->param('purchase_time'));
|
||||
my $file = $c->store_file_from_upload( $upload );
|
||||
|
||||
$organisation->create_related(
|
||||
|
@ -157,7 +157,7 @@ sub post_upload {
|
|||
buyer => $user,
|
||||
value => $transaction_value,
|
||||
proof_image => $file,
|
||||
purchase_time => $purchase_time,
|
||||
purchase_time => $c->format_db_datetime($purchase_time),
|
||||
}
|
||||
);
|
||||
|
||||
|
|
41
lib/Pear/LocalLoop/Plugin/Datetime.pm
Normal file
41
lib/Pear/LocalLoop/Plugin/Datetime.pm
Normal file
|
@ -0,0 +1,41 @@
|
|||
package Pear::LocalLoop::Plugin::Datetime;
|
||||
use Mojo::Base 'Mojolicious::Plugin';
|
||||
|
||||
use DateTime::Format::Strptime;
|
||||
|
||||
sub register {
|
||||
my ( $plugin, $app, $conf ) = @_;
|
||||
|
||||
$app->helper( iso_datetime_parser => sub {
|
||||
return DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S.%3N%z' );
|
||||
});
|
||||
|
||||
$app->helper( parse_iso_datetime => sub {
|
||||
my ( $c, $date_string ) = @_;
|
||||
return $c->iso_datetime_parser->parse_datetime(
|
||||
$date_string,
|
||||
);
|
||||
});
|
||||
|
||||
$app->helper( format_iso_datetime => sub {
|
||||
my ( $c, $datetime_obj ) = @_;
|
||||
return $c->iso_datetime_parser->parse_datetime(
|
||||
$datetime_obj,
|
||||
);
|
||||
});
|
||||
|
||||
$app->helper( db_datetime_parser => sub {
|
||||
return shift->schema->storage->datetime_parser;
|
||||
});
|
||||
|
||||
$app->helper( format_db_datetime => sub {
|
||||
my ( $c, $datetime_obj ) = @_;
|
||||
$datetime_obj->set_time_zone('UTC');
|
||||
return $c->db_datetime_parser->format_datetime(
|
||||
$datetime_obj,
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
1;
|
|
@ -6,7 +6,7 @@ use warnings;
|
|||
|
||||
use base 'DBIx::Class::Schema';
|
||||
|
||||
our $VERSION = 2;
|
||||
our $VERSION = 3;
|
||||
|
||||
__PACKAGE__->load_namespaces;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ __PACKAGE__->add_columns(
|
|||
},
|
||||
"purchase_time" => {
|
||||
data_type => "datetime",
|
||||
timezone => "UTC",
|
||||
is_nullable => 0,
|
||||
set_on_create => 1,
|
||||
},
|
||||
|
|
Reference in a new issue