MojoX::Date::Local - Mojo::Date, but in my timezone
use MojoX::Date::Local; say MojoX::Date::Local->new; # => Wed, 27 May 2020 17:39:43 PDT say MojoX::Date::Local->new->to_datetime # => 2020-05-27T17:39:43-07:00
This module lets you use Mojo::Date's concise date / time functionality within the context of your own time zone. That's mainly useful when logging to the console with a custom Mojo::Log format:
use Mojo::Log; use MojoX::Date::Local; my $logger = Mojo::Log->new; $logger->format( sub ($time, $level, @lines) { my ($time, $level, @lines) = @_; my $timestamp = MojoX::Date::Local->new($time)->to_datetime; my $prefix = "[$timestamp] [$level]"; my $message = join "\n", @lines, ""; return "$prefix $message"; } );
A MojoX::Date::Local provides the same methods as Mojo::Date, overriding two for its own purposes.
Render local date+time in RFC 3339 format, with timezone offset.
Render local date+time in RFC7231 format.
Mojolicious, Mojo::Date, POSIX
Copyright (C) Brian Wisti.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Brian Wisti <brianwisti@pobox.com>
To install MojoX::Date::Local, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MojoX::Date::Local
CPAN shell
perl -MCPAN -e shell install MojoX::Date::Local
For more information on module installation, please visit the detailed CPAN module installation guide.