Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cad439ef

Von Moritz Bunkus vor mehr als 14 Jahren hinzugefügt

  • ID cad439ef9ef417497e2970110b62ed467719c6c4
  • Vorgänger 88e5a86e
  • Nachfolger ea65e003

Hilfsfunktionen in DateTime

Conflicts:

SL/Locale.pm

Unterschiede anzeigen:

SL/Dispatcher.pm
}
use CGI qw( -no_xhtml);
use DateTime;
use English qw(-no_match_vars);
use SL::Auth;
use SL::LXDebug;
use SL::Locale;
use SL::Common;
use SL::Helper::DateTime;
use Form;
use List::Util qw(first);
use File::Basename;
SL/Helper/DateTime.pm
package DateTime;
sub now_local {
return shift->now(time_zone => $::locale->get_local_time_zone);
}
sub today_local {
return shift->now(time_zone => $::locale->get_local_time_zone)->truncate(to => 'day');
}
sub to_lxoffice {
return $::locale->format_date(\%::myconfig, $_[0]);
}
sub from_lxoffice {
return $::locale->parse_date_to_object(\%::myconfig, $_[1]);
}
1;
__END__
=encoding utf8
=head1 NAME
SL::Helpers::DateTime - helper functions for L<DateTime>
=head1 FUNCTIONS
=over 4
=item C<now_local>
Returns the current time with the time zone set to the local time zone.
=item C<today_local>
Returns the current date with the time zone set to the local time zone.
=item C<to_lxoffice>
Formats the date according to the current Lx-Office user's date
format.
=item C<from_lxoffice>
Parses a date string formatted in the current Lx-Office user's date
format and returns an instance of L<DateTime>.
=back
=head1 AUTHOR
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
=cut
SL/Locale.pm
$myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat};
}
sub get_local_time_zone {
my $self = shift;
$self->{local_time_zone} ||= DateTime::TimeZone->new(name => 'local');
return $self->{local_time_zone};
}
1;
scripts/console
use utf8;
use CGI qw( -no_xhtml);
use DateTime;
use SL::Auth;
use SL::Form;
use SL::Helper::DateTime;
use SL::Locale;
use SL::LXDebug;
use Data::Dumper;

Auch abrufbar als: Unified diff