view release on metacpan or search on metacpan
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
package AnyEvent::DateTime::Cron;
use warnings;
use strict;
use DateTime();
use DateTime::Event::Cron();
use DateTime::Event::Cron::Quartz();
use AnyEvent();
our $VERSION = 0.08;
#===================================
sub new {
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
foreach my $key ( keys %params ) {
die "Unknown param '$key'" unless $key =~ /^(time_zone|quartz)$/;
}
$params{time_zone} = DateTime::TimeZone->new(name => $params{time_zone})
if $params{time_zone};
$params{quartz} = 0 unless defined $params{quartz};
return bless {
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
die "No callback found for cron entry '$cron'"
unless $cb;
my $event;
if ($self->{_quartz}) {
$event = DateTime::Event::Cron::Quartz->new($cron);
}
else {
$event = DateTime::Event::Cron->new($cron);
}
my $id = ++$self->{_id};
$params{name} ||= $id;
my $job = $self->{_jobs}{$id} = {
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
my $time_zone = $self->{_time_zone};
AnyEvent->now_update();
my $now_epoch = AnyEvent->now;
my $now = DateTime->from_epoch( epoch => $now_epoch );
my $debug = $self->{_debug};
$now->set_time_zone($time_zone) if $time_zone;
for my $job (@_) {
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
AnyEvent::DateTime::Cron - AnyEvent crontab with DateTime::Event::Cron
=head1 VERSION
version 0.08
=head1 SYNOPSIS
AnyEvent::DateTime::Cron->new()
->add(
'* * * * *' => sub { warn "Every minute"},
'*/2 * * * *' => sub { warn "Every second minute"},
)
->start
->recv
$cron = AnyEvent::DateTime::Cron->new();
$cron->debug(1)->add(
'* * * * *', name => 'job_name', single => 1, sub {'foo'},
...
);
$cron->delete($job_id,$job_id...)
$cv = $cron->start;
$cv->recv;
AnyEvent::DateTime::Cron->new(time_zone => 'local');
->add(
'* * * * *' => sub { warn "Every minute"},
'*/2 * * * *' => sub { warn "Every second minute"},
)
->start
->recv
=head1 DESCRIPTION
L<AnyEvent::DateTime::Cron> is an L<AnyEvent> based crontab, which supports
all crontab formats recognised by L<DateTime::Event::Cron>.
It allows you to shut down a running instance gracefully, by waiting for
any running cron jobs to finish before exiting.
=head1 METHODS
=head2 new()
$cron = AnyEvent::DateTime::Cron->new(
time_zone => ...
quartz => 0/1
);
Creates a new L<AnyEvent::DateTime::Cron> instance - takes optional parameters
time_zone and quartz.
time_zone can will be used to set the time_zone for any DateTime objects that
are used internally.
if quartz is set to a true value then this class will use switch to using
L<DateTime::Event::Cron::Quartz> internally, which will allow the use of seconds
in the cron expression. See the DateTime::Event::Cron::Quartz for details on
writing a proper quartz cron expression.
=head2 add()
$cron->add(
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
=cut
__END__
# ABSTRACT: AnyEvent crontab with DateTime::Event::Cron
view all matches for this distribution
view release on metacpan or search on metacpan
- Bumped dependency on MooseX::StrictConstructor to 0.16 (RT #73229,
suggested by Andrew Main)
- Enforce dependency versions (RT #73193, suggested by Andrew Main)
0.55 Sat Dec 10 00:55:29 GMT 2011
- Replaced dependency on MooseX::Types::DateTimeX with
MooseX::Types::DateTime::MoreCoercions (RT #72472).
0.54 Sat Mar 21 21:23:32 BST 2011
- Fix for a naked qw() warning (patch by David Wheeler)
- Fixed path issues (patch by Pavel Karoukin)
*WARNING* THIS MIGHT BREAK EXISTING APPS *WARNING*
0.52 Thu Jul 2 09:17:11 BST 2009
- increase version prerequisites for some modules so that they
are known to work
0.51 Tue May 19 08:31:59 BST 2009
- use MooseX::Types::DateTimeX so that we work with latest Moose
(noticed by Ted Zlatanov)
0.50 Wed Jan 21 10:42:00 GMT 2009
- add support for an expires header when putting an object to
Net::Amazon::S3::Client::Object
0.45 Wed Aug 20 17:06:49 BST 2008
- make add_key, head_key etc. return all the headers, not
just the X-Amazon ones (patch by Andrew Hanenkamp)
- require IO::File 1.14 (noticed by tsw)
- remove DateTime::Format::Strptime prerequisite as it was not
being used (noticed by Yen-Ming Lee)
- do not try and parse non-XML errors (patch by lostlogic)
- make it possible to store and delete the key "0"
(patch by Joey Hess)
- make it possible to store empty files (patch by BDOLAN)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
$VERSION = eval $VERSION;
use AnyEvent;
use Scalar::Util qw(weaken);
use Safe::Isa;
use DateTime;
use DateTime::Event::Cron;
use namespace::clean;
has 'cb' => (is => 'ro', required => 1);
has 'time_zone' => (is => 'ro');
has '_cron' => (
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
required => 1,
init_arg => 'cron',
coerce => sub {
my $cron = shift;
if (!ref $cron) {
$cron = DateTime::Event::Cron->new($cron);
}
if ($cron->$_can('next')) {
return sub { $cron->next(@_) };
}
elsif ($cron->$_can('get_next_valid_time_after')) {
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
}
sub create_timer {
my $self = shift;
weaken $self;
my $now = DateTime->from_epoch(epoch => AnyEvent->now);
$now->set_time_zone( $self->time_zone ) if $self->time_zone;
my $next = $self->next_event($now);
return
if not $next;
my $interval = $next->subtract_datetime_absolute($now)->in_units('nanoseconds') / 1_000_000_000;
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
));
}
sub next_event {
my $self = shift;
my $now = shift || DateTime->from_epoch(epoch => AnyEvent->now);
$now->set_time_zone( $self->time_zone ) if $self->time_zone;
$self->_cron->($now);
}
1;
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
=over 4
=item cron
Required. A cron rule, either in string form or as a
L<DateTime::Event::Cron>, L<DateTime::Event::Cron::Quartz>, or
L<DateTime::Set> object.
=item cb
Required. The callback to call for the cron events.
lib/AnyEvent/Timer/Cron.pm view on Meta::CPAN
=over 4
=item L<AnyEvent::Cron>
=item L<AnyEvent::DateTime::Cron>
=back
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
use strict;
use warnings;
use AnyEvent::HTTP qw(http_request);
use Carp qw(croak);
use DateTime;
use DateTime::Format::ISO8601;
use MIME::Base64 qw(encode_base64);
use URI;
use XML::Parser;
use XML::Writer;
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
}
sub parse_datetime {
my ( $self, $str ) = @_;
return DateTime::Format::ISO8601->parse_datetime($str);
}
sub format_datetime {
my ( $self, $datetime ) = @_;
my @fields = qw/year month day hour minute second/;
my %attrs = map { $_ => $datetime->$_() } @fields;
my $offset = DateTime::TimeZone->offset_as_string($datetime->offset);
return sprintf '%04d-%02d-%02dT%02d:%02d:%02d%s', @attrs{@fields}, $offset;
}
sub handle_error {
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
foreach my $k (@keys) {
my $v = $attrs->{$k};
my @xml_attrs;
push @xml_attrs, (nil => 'true') unless defined $v;
if(ref($v) eq 'DateTime') {
push @xml_attrs, (type => 'datetime');
$v = $self->format_datetime($v);
}
my $nk = $k;
view all matches for this distribution
view release on metacpan or search on metacpan
benchmarks/bench.pl view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use AnyMongo;
use MongoDB;
use DateTime;
use feature 'say';
use Benchmark qw(:all);
my $tries = 50000;
benchmarks/bench.pl view on Meta::CPAN
};
my $large_doc = {
'base_url' => 'http://www.example.com/test-me',
'total_word_count' => 6743,
'access_time' => DateTime->now,
'meta_tags' => {
'description' => 'i am a long description string',
'author' => 'Holly Man',
'dynamically_created_meta_tag' => 'who know\n what'
},
view all matches for this distribution
view release on metacpan or search on metacpan
inc/ExtUtils/AutoInstall.pm view on Meta::CPAN
#line 1 "inc/ExtUtils/AutoInstall.pm - /Library/Perl/5.8.1/ExtUtils/AutoInstall.pm"
# $File: //member/autrijus/ExtUtils-AutoInstall/lib/ExtUtils/AutoInstall.pm $
# $Revision: #9 $ $Change: 9532 $ $DateTime: 2004/01/01 06:47:30 $ vim: expandtab shiftwidth=4
package ExtUtils::AutoInstall;
$ExtUtils::AutoInstall::VERSION = '0.56';
use strict;
view all matches for this distribution
view release on metacpan or search on metacpan
$url .= $self->_urlEncodeVars($param_hash, $sep);
return $url;
}
sub _formatDateTime {
my ($self, $time) = @_;
$time = time() unless $time;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time);
sub _log {
my ($self, @rest) = @_;
local(*LOG);
open(LOG, ">>/tmp/generic_auth_log");
my $date = $self->_formatDateTime;
print LOG "$date - ", @rest, "\n";
close LOG;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Config/Preproc/Server/Probe.pm view on Meta::CPAN
use strict;
use warnings;
use File::Spec;
use IPC::Open3;
use Shell::GetEnv;
use DateTime::Format::ISO8601;
use Symbol 'gensym';
use Carp;
sub new {
my $class = shift;
lib/Apache/Config/Preproc/Server/Probe.pm view on Meta::CPAN
$self->{version}{name} = $1;
$self->{version}{number} = $2;
$self->{version}{platform} = $3;
} elsif (/^Server built:\s+(.+)/) {
$self->{version}{built} =
DateTime::Format::ISO8601->parse_datetime($1);
}
}, '-v');
}
return $self->{version}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Defaults.pm view on Meta::CPAN
use strict;
use warnings;
use File::Spec;
use IPC::Open3;
use Shell::GetEnv;
use DateTime::Format::Strptime;
use Text::ParseWords;
use Symbol 'gensym';
use Carp;
our $VERSION = '1.03';
lib/Apache/Defaults.pm view on Meta::CPAN
$self->{name} = $1;
$self->{version} = $2;
$self->{platform} = $3;
} elsif (/^Server built:\s+(.+)/) {
$self->{built} =
DateTime::Format::Strptime->new(
pattern => '%b %d %Y %H:%M%S',
locale => 'en_US',
time_zone => 'UTC',
on_error => 'undef'
)->parse_datetime($1);
lib/Apache/Defaults.pm view on Meta::CPAN
=head2 built
$d = $x->built;
Returns a B<DateTime> object, representing the time when the server
was built.
=head2 loaded_with
APR tools with which the server is loaded.
view all matches for this distribution
view release on metacpan or search on metacpan
HanConvert.pm view on Meta::CPAN
# $File: //member/autrijus/Apache-Filter-HanConvert/HanConvert.pm $ $Author: autrijus $
# $Revision: #4 $ $Change: 2690 $ $DateTime: 2002/12/12 06:47:15 $
package Apache::Filter::HanConvert;
$Apache::Filter::HanConvert::VERSION = '0.02';
use strict;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Gallery.pm view on Meta::CPAN
my $filetitle = $file;
$filetitle =~ s/_/ /g if $r->dir_config('GalleryUnderscoresToSpaces');
my %file_vars = (FILEURL => uri_escape($fileurl, $escape_rule),
FILE => $filetitle,
DATE => $imageinfo->{DateTimeOriginal} ? $imageinfo->{DateTimeOriginal} : '', # should this really be a stat of the file instead of ''?
SRC => uri_escape($uri."/.cache/$cached", $escape_rule),
HEIGHT => (grep($rotate==$_, (1, 3)) ? $thumbnailwidth : $thumbnailheight),
WIDTH => (grep($rotate==$_, (1, 3)) ? $thumbnailheight : $thumbnailwidth),
SELECT => $select_mode?'<input type="checkbox" name="selection" value="'.$file.'"> ':'',);
$tpl_vars{FILES} .= $templates{picture}->fill_in(HASH => {%tpl_vars,
lib/Apache/Gallery.pm view on Meta::CPAN
$tpl_vars{COMMENT} = encode("iso-8859-1", $comment);
} else {
$tpl_vars{COMMENT} = '';
}
my @infos = split /, /, $r->dir_config('GalleryInfo') ? $r->dir_config('GalleryInfo') : 'Picture Taken => DateTimeOriginal, Flash => Flash';
my $foundinfo = 0;
my $exifvalues;
foreach (@infos) {
my ($human_key, $exif_key) = (split " => ")[0,1];
lib/Apache/Gallery.pm view on Meta::CPAN
unless (defined($imageinfo->{width}) and defined($imageinfo->{height})) {
$imageinfo->{width} = $width;
$imageinfo->{height} = $height;
}
my @infos = split /, /, $r->dir_config('GalleryInfo') ? $r->dir_config('GalleryInfo') : 'Picture Taken => DateTimeOriginal, Flash => Flash';
foreach (@infos) {
my ($human_key, $exif_key) = (split " => ")[0,1];
if (defined($exif_key) && defined($imageinfo->{$exif_key})) {
my $value = "";
lib/Apache/Gallery.pm view on Meta::CPAN
if ($r->dir_config('GalleryUseFileDate') &&
($r->dir_config('GalleryUseFileDate') eq '1'
|| !$imageinfo->{"Picture Taken"} )) {
my $st = stat($file);
$imageinfo->{"DateTimeOriginal"} = $imageinfo->{"Picture Taken"} = scalar localtime($st->mtime) if $st;
}
return $imageinfo;
}
lib/Apache/Gallery.pm view on Meta::CPAN
You can view all the keys from the EXIF header using this perl-oneliner:
perl C<-e> 'use Data::Dumper; use Image::Info qw(image_info); print Dumper(image_info(shift));' filename.jpg
Default is: 'Picture Taken => DateTimeOriginal, Flash => Flash'
=item B<GallerySizes>
Defines which widths images can be scaled to. Images cannot be
scaled to other widths than the ones you define with this option.
lib/Apache/Gallery.pm view on Meta::CPAN
You can also set it to 'values' which will make A::G parse
the configured values into the var $EXIFVALUES as 'value | value | value'
If you set this option to 'variables' the items you configure in GalleryInfo
will be available to your templates as $EXIF_<KEYNAME> (in all uppercase).
That means that with the default setting "Picture Taken => DateTimeOriginal,
Flash => Flash" you will have the variables $EXIF_DATETIMEORIGINAL and
$EXIF_FLASH available to your templates. You can place them
anywhere you want.
=item B<GalleryRootPath>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/SWIT/Test.pm view on Meta::CPAN
return $self->mech->content;
}
sub _decode_utf8_arr {
my $arr = shift;
return $arr if ref($arr) ne 'ARRAY'; # DateTime for example
for (my $i = 0; $i < @$arr; $i++) {
my $r = ref($arr->[$i]);
$arr->[$i] = $r ? $r eq 'ARRAY' ? _decode_utf8_arr($arr->[$i])
: _decode_utf8($arr->[$i])
: Encode::decode_utf8($arr->[$i]);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/SdnFw/js/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js view on Meta::CPAN
(function(){tinymce.create("tinymce.plugins.InsertDateTime",{init:function(a,b){var c=this;c.editor=a;a.addCommand("mceInsertDate",function(){var d=c._getDateTime(new Date(),a.getParam("plugin_insertdate_dateFormat",a.getLang("insertdatetime.date_fmt...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Solr/XML.pm view on Meta::CPAN
return \%d;
}
elsif(ref $data eq 'ARRAY')
{ return [ map _cleanup_parsed($_), @$data ];
}
elsif(ref $data eq 'DateTime')
{ return $data;
}
else {panic ref $data || $data}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/API.pm view on Meta::CPAN
my $self = shift( @_ );
my $dt;
if( @_ )
{
return( $self->error( "Date time provided (", ( $_[0] // 'undef' ), ") is not an object." ) ) if( !Scalar::Util::blessed( $_[0] ) );
return( $self->error( "Object provided (", ref( $_[0] ), ") is not a DateTime object." ) ) if( !$_[0]->isa( 'DateTime' ) );
$dt = shift( @_ );
}
$dt = DateTime->now if( !defined( $dt ) );
my $fmt = Apache2::API::DateTime->new;
$dt->set_formatter( $fmt );
return( $dt );
}
sub is_perl_option_enabled { return( shift->_try( 'request', 'is_perl_option_enabled', @_ ) ); }
lib/Apache2/API.pm view on Meta::CPAN
Get the localised version of the string passed as an argument.
This is supposed to be superseded by the package inheriting from L<Apache2::API>, if any.
=head2 header_datetime( DateTime object )
Given a L<DateTime> object, this sets it to GMT time zone and set the proper formatter (L<Apache2::API::DateTime>) so that the stringification is compliant with HTTP headers standard.
=head2 is_perl_option_enabled
Checks if perl option is enabled in the Virtual Host and returns a boolean value
lib/Apache2/API.pm view on Meta::CPAN
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API::DateTime>, L<Apache2::API::Query>, L<Apache2::API::Request>, L<Apache2::API::Request::Params>, L<Apache2::API::Request::Upload>, L<Apache2::API::Response>, L<Apache2::API::Status>
L<Apache2::Request>, L<Apache2::RequestRec>, L<Apache2::RequestUtil>
=head1 COPYRIGHT & LICENSE
view all matches for this distribution
view release on metacpan or search on metacpan
Apache2::RequestIO
Apache2::RequestRec
Apache2::RequestUtil
Apache::Session
Apache::Session::File
DateTime
Digest::SHA
English
Exception::Class
ExtUtils::MakeMaker
File::Spec
view all matches for this distribution
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
"APR::Pool" => "0.009",
"Data::Compare" => "1.27",
"Data::Printer" => "0.40",
"Test::More" => "1.302181",
"Test::Output" => "1.031",
"DateTime" => "1.51",
},
AUTHOR => 'jeff <jeff@lipsia.de>',
LICENSE => 'perl_5',
PM => {
'RequestRec.pm' => '$(INST_LIBDIR)/RequestRec.pm',
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/SSI.pm view on Meta::CPAN
$format ||= $self->{timefmt};
# Quotes are important as they are used to stringify overloaded $time
my $params = { epoch => "$time" };
$params->{time_zone} = ( $tzone || 'local' );
$params->{locale} = $env->{lang} if( length( $env->{lang} ) );
require DateTime;
require DateTime::Format::Strptime;
my $tz;
# DateTime::TimeZone::Local will die ungracefully if the local timezeon is not set with the error:
# "Cannot determine local time zone"
local $@;
# try-catch
eval
{
require DateTime::TimeZone;
$tz = DateTime::TimeZone->new( name => 'local' );
};
if( $@ )
{
$tz = DateTime::TimeZone->new( name => 'UTC' );
warn( "Your system is missing key timezone components. Reverting to UTC instead of local time zone.\n" );
}
# try-catch
my $rv = eval
{
my $dt = DateTime->from_epoch( %$params );
if( length( $format ) )
{
my $fmt = DateTime::Format::Strptime->new(
pattern => $format,
time_zone => ( $params->{time_zone} || $tz ),
locale => $dt->locale->code,
);
$dt->set_formatter( $fmt );
lib/Apache2/SSI.pm view on Meta::CPAN
return( $dt->format_cldr( $dt->locale->date_format_full ) );
}
};
if( $@ )
{
$self->error( "An error occurred getting a DateTime object for time \"$time\" with format \"$format\": $@" );
return( $self->errmsg );
}
return( $rv );
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/WebApp/Extra/Admin.pm view on Meta::CPAN
=back
=head1 PREREQUISITES
Apache2::WebApp
Apache2::WebApp::Plugin::DateTime
Apache2::WebApp::Plugin::DBI (optional)
Apache::Htpasswd
Params::Validate
=head1 INSTALLATION
lib/Apache2/WebApp/Extra/Admin.pm view on Meta::CPAN
personal information (including passwords) may be exposed.
=head1 SEE ALSO
L<Apache2::WebApp>, L<Apache2::WebApp::Plugin::DBI>,
L<Apache2::WebApp::Plugin::DateTime>, L<Apache::Htpasswd>
=head1 AUTHOR
Marc S. Brooks, E<lt>mbrooks@cpan.orgE<gt> L<http://mbrooks.info>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/WebApp/Plugin/DateTime.pm view on Meta::CPAN
#----------------------------------------------------------------------------+
#
# Apache2::WebApp::Plugin::DateTime - Plugin providing Date/Time methods
#
# DESCRIPTION
# Common methods for dealing with Date/Time.
#
# AUTHOR
lib/Apache2/WebApp/Plugin/DateTime.pm view on Meta::CPAN
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
#----------------------------------------------------------------------------+
package Apache2::WebApp::Plugin::DateTime;
use strict;
use base 'Apache2::WebApp::Plugin';
use Date::Calc qw( Date_to_Days Delta_Days Today );
use Date::Manip;
lib/Apache2/WebApp/Plugin/DateTime.pm view on Meta::CPAN
__END__
=head1 NAME
Apache2::WebApp::Plugin::DateTime - Plugin providing Date/Time methods
=head1 SYNOPSIS
my $obj = $c->plugin('DateTime')->method( ... ); # Apache2::WebApp::Plugin::DateTime->method()
or
$c->plugin('DateTime')->method( ... );
=head1 DESCRIPTION
Common methods for dealing with Date/Time.
lib/Apache2/WebApp/Plugin/DateTime.pm view on Meta::CPAN
=head1 INSTALLATION
From source:
$ tar xfz Apache2-WebApp-Plugin-DateTime-0.X.X.tar.gz
$ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib
$ make
$ make test
$ make install
Perl one liner using CPAN.pm:
$ perl -MCPAN -e 'install Apache2::WebApp::Plugin::DateTime'
Use of CPAN.pm in interactive mode:
$ perl -MCPAN -e shell
cpan> install Apache2::WebApp::Plugin::DateTime
cpan> quit
Just like the manual installation of Perl modules, the user may need root access during
this process to insure write permission is allowed within the installation directory.
lib/Apache2/WebApp/Plugin/DateTime.pm view on Meta::CPAN
Return the total days between dates.
my $date1 = 'Sun Oct 18 15:14:48 2009'; # then and
my $date2 = localtime(time); # now
my $delta = $c->plugin('DateTime')->days_between_dates( $date1, $date2 );
=head2 format_time
Convert seconds-since-epoch to a human readable format.
my $date = $c->plugin('DateTime')->format_time( $unix_time, '%a %b %d %T %Y' );
See L<Date::Format> for character conversion specification.
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/WebApp/Plugin.pm view on Meta::CPAN
L<Apache2::WebApp::Plugin::CGI> - Common methods for dealing with HTTP requests.
L<Apache2::WebApp::Plugin::Cookie> - Common methods for creating and manipulating web browser cookies.
L<Apache2::WebApp::Plugin::DateTime> - Common methods for dealing with Date/Time.
L<Apache2::WebApp::Plugin::DBI> - Database interface wrapper for MySQL, PostGre, and Oracle.
L<Apache2::WebApp::Plugin::File> - Common methods for processing and outputting files.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ApacheLog/Compressor.pm view on Meta::CPAN
use Socket qw(inet_aton inet_ntoa);
use Date::Parse qw(str2time);
use List::Util qw(min);
use URI;
use URI::Escape qw(uri_unescape);
use DateTime;
use Encode qw(encode_utf8 decode_utf8 FB_DEFAULT is_utf8 FB_CROAK);
use POSIX qw{strftime};
our $VERSION = '0.005';
lib/ApacheLog/Compressor.pm view on Meta::CPAN
$info{$_} = $self->from_cache($_, $info{$_}) for qw(vhost user url query useragent refer);
$info{server} = $self->{server};
undef $info{$_} for grep { $info{$_} eq '-' } qw(user refer size useragent);
undef $info{query} unless defined $info{query} && length $info{query};
#DateTime->from_epoch(epoch => $self->{timestamp})->strftime("%d/%b/%Y:%H:%M:%S %z");
$info{timestamp} = strftime("%d/%b/%Y:%H:%M:%S %z", gmtime($self->{timestamp}));
return \%info;
}
=head2 data_to_text
lib/ApacheLog/Compressor.pm view on Meta::CPAN
$self->from_cache('vhost', $data->{vhost}),
$data->{duration},
$data->{ip},
'-',
$self->from_cache('user', $data->{user}),
'[' . DateTime->from_epoch(epoch => $self->{timestamp})->strftime("%d/%b/%Y:%H:%M:%S %z") . ']',
'"' . $data->{method} . ' ' . $self->from_cache('url', $data->{url}) . (length $q ? "?$q" : "") . ' HTTP/' . ($data->{ver} ? '1.1' : '1.0') . '"',
$data->{result},
$data->{size},
'"' . $self->from_cache('useragent', $data->{useragent}) . '"',
'"' . $self->from_cache('refer', $data->{refer}) . '"',
view all matches for this distribution
view release on metacpan or search on metacpan
script/acme-cpanauthors view on Meta::CPAN
#state $process_array;
#state $process_hash;
#if (!$process_array) { $process_array = sub { my $a = shift; for my $e (@$a) { my $ref=ref($e);
# if ($ref && $refs{ $e }++) { if (++$ctr_circ <= 1) { $e = Clone::PP::clone($e); redo } else { $e = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $e = $e->epoch; $ref = ref($e) }
# elsif ($ref eq 'JSON::PP::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $e = $e->bstr; $ref = ref($e) }
# elsif ($ref eq 'Regexp') { $e = "$e"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $e = ${ $e }; $ref = ref($e) }
script/acme-cpanauthors view on Meta::CPAN
# elsif ($ref) { $e = $ref; $ref = "" }
#} } }
#if (!$process_hash) { $process_hash = sub { my $h = shift; for my $k (keys %$h) { my $ref=ref($h->{$k});
# if ($ref && $refs{ $h->{$k} }++) { if (++$ctr_circ <= 1) { $h->{$k} = Clone::PP::clone($h->{$k}); redo } else { $h->{$k} = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $h->{$k} = $h->{$k}->epoch; $ref = ref($h->{$k}) }
# elsif ($ref eq 'JSON::PP::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $h->{$k} = $h->{$k}->bstr; $ref = ref($h->{$k}) }
# elsif ($ref eq 'Regexp') { $h->{$k} = "$h->{$k}"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $h->{$k} = ${ $h->{$k} }; $ref = ref($h->{$k}) }
script/acme-cpanauthors view on Meta::CPAN
#} } }
#%refs = (); $ctr_circ=0;
#for ($data) { my $ref=ref($_);
# if ($ref && $refs{ $_ }++) { if (++$ctr_circ <= 1) { $_ = Clone::PP::clone($_); redo } else { $_ = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $_ = $_->epoch; $ref = ref($_) }
# elsif ($ref eq 'JSON::PP::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $_ = $_->bstr; $ref = ref($_) }
# elsif ($ref eq 'Regexp') { $_ = "$_"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $_ = ${ $_ }; $ref = ref($_) }
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Acmeman.pm view on Meta::CPAN
use Crypt::OpenSSL::RSA;
use Crypt::OpenSSL::X509;
use File::Basename;
use File::Path qw(make_path);
use File::Spec;
use DateTime::Format::Strptime;
use LWP::UserAgent;
use LWP::Protocol::https;
use Socket qw(inet_ntoa);
use Sys::Hostname;
use Pod::Usage;
lib/App/Acmeman.pm view on Meta::CPAN
}
}
my $expiry = $x509->notAfter();
my $strp = DateTime::Format::Strptime->new(
pattern => '%b %d %H:%M:%S %Y %Z',
time_zone => 'GMT'
);
my $ts = $strp->parse_datetime($expiry)->epoch;
my $now = time();
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MojoX/Aliyun.pm view on Meta::CPAN
use v5.10;
use Carp qw/croak/;
use Mojo::Base -base;
use Mojo::UserAgent;
use DateTime;
use Digest::SHA qw(hmac_sha1_base64);
use URI::Escape;
use Data::UUID;
our $VERSION = '0.02';
lib/MojoX/Aliyun.pm view on Meta::CPAN
$Version = '2014-08-15' if $url =~ 'rds\.';
my $ug = Data::UUID->new;
my $uuid = $ug->to_string($ug->create());
my %auth_params = (
Timestamp => sprintf("%s", DateTime->now()),
Format => 'JSON',
Version => $Version,
SignatureMethod => 'HMAC-SHA1',
SignatureVersion => '1.0',
SignatureNonce => $uuid,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/AltSQL.pm view on Meta::CPAN
A block to be eval'ed. You may use $self to refer to the L<App::AltSQL::Term> object
=item B<%t{...}>
The argument to this option will be passed to L<DateTime> C<strftime> for the current time
=back
=item B<plugins>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/ArchiveDevelCover.pm view on Meta::CPAN
package App::ArchiveDevelCover;
use 5.010;
use Moose;
use MooseX::Types::Path::Class;
use DateTime;
use File::Copy;
use HTML::TableExtract;
use experimental qw(switch);
# ABSTRACT: Archive Devel::Cover reports
lib/App/ArchiveDevelCover.pm view on Meta::CPAN
else {
say "Cannot find 'coverage.html' in ".$self->from.'. Aborting';
exit;
}
}
has 'runtime' => (is=>'ro',isa=>'DateTime',lazy_build=>1,traits=> ['NoGetopt'],);
sub _build_runtime {
my $self = shift;
return DateTime->from_epoch(epoch=>$self->coverage_html->stat->mtime);
}
has 'archive_html' => (is=>'ro',isa=>'Path::Class::File',lazy_build=>1,traits=> ['NoGetopt']);
sub _build_archive_html {
my $self = shift;
unless (-e $self->to->file('index.html')) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/BackupPlan.pm view on Meta::CPAN
use 5.012003;
use strict;
use warnings;
use Config;
use DateTime;
use Time::Local;
use XML::DOM;
use Log::Log4perl qw(:easy);
use App::BackupPlan::Policy;
use App::BackupPlan::Utils qw(fromISO2TS fromTS2ISO addSpan subSpan);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/BookmarkFeed.pm view on Meta::CPAN
use File::Spec;
use Mojo::SQLite;
use Mojo::Template;
use File::Slurper qw(read_text write_text);
use CommonMark qw(:node :event);
use DateTime;
use DateTime::Format::ISO8601;
sub main (@files) {
my $feed_file = pop(@files);
die "Usage:\nbookmark-feed markdown-files... feed-file\n" unless @files;
my ($filename, $dirs, $suffix) = fileparse($feed_file, ".rss", ".xml");
lib/App/BookmarkFeed.pm view on Meta::CPAN
$sql->migrations->from_data->migrate;
my $db = $sql->db;
for (@files) { die "$_ is not readable\n" unless -r $_ }
my @items;
for my $file (@files) {
my $dt = DateTime->from_epoch(epoch => (stat($file))[9]);
my $md = read_text($file);
my $parser = CommonMark::Parser->new;
$parser->feed($md);
my $doc = $parser->finish;
push(@items, to_items($doc, $dt));
lib/App/BookmarkFeed.pm view on Meta::CPAN
{ },
{
order_by => {-desc => 'date'},
limit => 40,
})->hashes;
$_->{date} = DateTime::Format::ISO8601
->parse_datetime($_->{date})
->strftime("%a, %d %b %Y %H:%M:%S %z")
for @$items;
my $feed = $mt->render(<<'EOT', { items => $items});
<rss version="2.0">
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/CPAN2Pkg/UI/Text.pm view on Meta::CPAN
use warnings;
package App::CPAN2Pkg::UI::Text;
# ABSTRACT: text interface for cpan2pkg
$App::CPAN2Pkg::UI::Text::VERSION = '3.004';
use DateTime;
use List::Util qw{ first };
use Moose;
use MooseX::Has::Sugar;
use MooseX::POE;
use MooseX::SemiAffordanceAccessor;
lib/App/CPAN2Pkg/UI/Text.pm view on Meta::CPAN
my ($self, $modname, $line) = @_[OBJECT, ARG0 .. $#_ ];
$self->_outputs->{$modname} .= "$line\n";
};
event log_comment => sub {
my ($self, $module, $line) = @_[OBJECT, ARG0 .. $#_ ];
my $timestamp = DateTime->now(time_zone=>"local")->hms;
$line =~ s/\n$//;
print "$timestamp [$module] $line\n";
};
event log_result => sub {
my ($self, $module, $result) = @_[OBJECT, ARG0 .. $#_ ];
my $timestamp = DateTime->now(time_zone=>"local")->hms;
local $Term::ANSIColor::AUTORESET = 1;
print BLUE "$timestamp [$module] => $result\n";
};
event log_step => sub {
my ($self, $module, $step) = @_[OBJECT, ARG0 .. $#_ ];
my $timestamp = DateTime->now(time_zone=>"local")->hms;
local $Term::ANSIColor::AUTORESET = 1;
print BOLD "$timestamp [$module] ** $step\n";
};
}
event module_state => sub {
my ($self, $module) = @_[OBJECT, ARG0 .. $#_ ];
my $app = App::CPAN2Pkg->instance;
my $modname = $module->name;
my $timestamp = DateTime->now(time_zone=>"local")->hms;
if ( $module->local->status eq "error" or
$module->upstream->status eq "error" ) {
local $Term::ANSIColor::AUTORESET = 1;
print RED "$timestamp [$modname] error encountered\n";
view all matches for this distribution