+=cut
+
+sub LocaleObj {
+ my $self = shift;
+
+ my $lang = $self->CurrentUser->UserObj->Lang;
+ unless ($lang) {
+ require I18N::LangTags::Detect;
+ $lang = ( I18N::LangTags::Detect::detect(), 'en' )[0];
+ }
+
+ return DateTime::Locale->load($lang);
+}
+
+=head3 LocalizedDateTime
+
+Returns date and time as string, with user localization.
+
+Supports arguments: C<DateFormat> and C<TimeFormat> which may contains date and
+time format as specified in L<DateTime::Locale> (default to full_date_format and
+medium_time_format), C<AbbrDay> and C<AbbrMonth> which may be set to 0 if
+you want full Day/Month names instead of abbreviated ones.
+
+=cut
+
+sub LocalizedDateTime
+{
+ my $self = shift;
+ my %args = ( Date => 1,
+ Time => 1,
+ Timezone => '',
+ DateFormat => '',
+ TimeFormat => '',
+ AbbrDay => 1,
+ AbbrMonth => 1,
+ @_,
+ );
+
+ # Require valid names for the format methods
+ my $date_format = $args{DateFormat} =~ /^\w+$/
+ ? $args{DateFormat} : 'date_format_full';
+
+ my $time_format = $args{TimeFormat} =~ /^\w+$/
+ ? $args{TimeFormat} : 'time_format_medium';
+
+ my $formatter = $self->LocaleObj;
+ $date_format = $formatter->$date_format;
+ $time_format = $formatter->$time_format;
+ $date_format =~ s/EEEE/EEE/g if ( $args{'AbbrDay'} );
+ $date_format =~ s/MMMM/MMM/g if ( $args{'AbbrMonth'} );
+
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
+ $self->Localtime($args{'Timezone'});
+ $mon++;
+ my $tz = $self->Timezone($args{'Timezone'});
+
+ # FIXME : another way to call this module without conflict with local
+ # DateTime method?
+ my $dt = DateTime::->new( locale => $formatter,
+ time_zone => $tz,
+ year => $year,
+ month => $mon,
+ day => $mday,
+ hour => $hour,
+ minute => $min,
+ second => $sec,
+ nanosecond => 0,
+ );
+
+ if ( $args{'Date'} && !$args{'Time'} ) {
+ return $dt->format_cldr($date_format);
+ } elsif ( !$args{'Date'} && $args{'Time'} ) {
+ return $dt->format_cldr($time_format);
+ } else {
+ return $dt->format_cldr($date_format) . " " . $dt->format_cldr($time_format);
+ }
+}
+
+=head3 ISO
+
+Returns the object's date in ISO format C<YYYY-MM-DD mm:hh:ss>.
+ISO format is locale independant, but adding timezone offset info
+is not implemented yet.
+
+Supports arguments: C<Timezone>, C<Date>, C<Time> and C<Seconds>.
+See </Output formatters> for description of arguments.
+
+=cut
+
+sub ISO {
+ my $self = shift;
+ my %args = ( Date => 1,
+ Time => 1,
+ Timezone => '',
+ Seconds => 1,
+ @_,
+ );
+ # 0 1 2 3 4 5 6 7 8 9
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
+ $self->Localtime($args{'Timezone'});