ePages 6.11.0 - DE_EPAGES/Core/API/Object/DateTimeFormatter.pm

Package DE_EPAGES::Core::API::Object::DateTimeFormatter

Formatter and parser for locale-dependent time and date strings. Based on DateTime::Format::Strptime.

Example
my $Formatter = DE_EPAGES::Core::API::Object::DateTimeFormatter->new(
    locale => 'de_DE',
);
my $Date   = $Formatter->parse_datetime( 'Donnerstag, 7. Oktober 2004', 'date' );
my $String = $Formatter->format_datetime( $Date, 'date', 'long' );

Functions

formatString
format_datetime
new
parse_datetime

formatString

returns formats string for parse_datetime and format_datetime

Syntax
$FormatString = $Formatter->formatString($type, $formattype);
Input
$type (string)
date/time/datetime
$formattype (string)
short/medium/long/full (optional short)
Return
$FormatString (string)
pattern for DateTime::Format::Strptime

format_datetime

Formats the value

Syntax
$FormattedDateTime = $Formatter->format_datetime($value, $type, $formattype);
Input
$value (object)
datetime
$type (string)
date/date_tz/time/time_tz/datetime
$formattype (string)
(optional) short/medium/long/full
or custom strftime format, for example '%Y-%m-%d'
(default: short)
Return
$FormattedDateTime (string)
formatted value

new

Creates a formatter for dates and/or time strings.

Syntax
$Formatter = DE_EPAGES::Core::API::Object::DateTimeFormatter->new(%options);
Input
%options (hash)
keys
  • locale - (optional) locale id, example: 'en_US',
    default: server locale - string
  • time_zone - (optional) time zone, example: '+01:00',
    default: server time zone - string
Return
$Formatter (object)
formatter object

parse_datetime

Return the internal value of a formatted value.

Syntax
$Value = $Formatter->parse_datetime($FormattedDateTime, $type, $formattype);
Input
$FormattedDateTime (string)
formatted value
$type (string)
date/time/datetime
$formattype (string)
(optional) short/medium/long/full
or custom strftime format, for example '%Y-%m-%d'
(default: short)
Return
$value (DateTime object)
datetime value