Skip to content

Instantly share code, notes, and snippets.

@ywatase
Created January 5, 2015 08:26
Show Gist options
  • Save ywatase/f5f397764a879eaeb619 to your computer and use it in GitHub Desktop.
Save ywatase/f5f397764a879eaeb619 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DateTime::Format::HTTP;
use DateTime;
sub t {
my ($y,$m,$d) = split /\//, shift;
my $dt = DateTime->new(year => $y, month => $m, day => $d, hour => 0, minute=> 0, second => 0);
my $class = 'DateTime::Format::HTTP';
say "$class : ", $class->format_datetime($dt); # Format as GMT ASCII time
say "DateTime(YYYY-MM-dd): ", $dt->format_cldr('YYYY-MM-dd');
say "DateTime(yyyy-MM-dd): ", $dt->format_cldr('yyyy-MM-dd');
say "DateTime(yyyy-mm-dd): ", $dt->format_cldr('yyyy-mm-dd');
say "DateTime(YYYY-MM-DD): ", $dt->format_cldr('YYYY-MM-DD');
# $time = $class->parse_datetime($string); # convert ASCII date to machine time
}
t('2013/12/31');
t('2014/12/31');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment