Revision cad439ef
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/Dispatcher.pm | ||
---|---|---|
9 | 9 |
} |
10 | 10 |
|
11 | 11 |
use CGI qw( -no_xhtml); |
12 |
use DateTime; |
|
12 | 13 |
use English qw(-no_match_vars); |
13 | 14 |
use SL::Auth; |
14 | 15 |
use SL::LXDebug; |
15 | 16 |
use SL::Locale; |
16 | 17 |
use SL::Common; |
18 |
use SL::Helper::DateTime; |
|
17 | 19 |
use Form; |
18 | 20 |
use List::Util qw(first); |
19 | 21 |
use File::Basename; |
SL/Helper/DateTime.pm | ||
---|---|---|
1 |
package DateTime; |
|
2 |
|
|
3 |
sub now_local { |
|
4 |
return shift->now(time_zone => $::locale->get_local_time_zone); |
|
5 |
} |
|
6 |
|
|
7 |
sub today_local { |
|
8 |
return shift->now(time_zone => $::locale->get_local_time_zone)->truncate(to => 'day'); |
|
9 |
} |
|
10 |
|
|
11 |
sub to_lxoffice { |
|
12 |
return $::locale->format_date(\%::myconfig, $_[0]); |
|
13 |
} |
|
14 |
|
|
15 |
sub from_lxoffice { |
|
16 |
return $::locale->parse_date_to_object(\%::myconfig, $_[1]); |
|
17 |
} |
|
18 |
|
|
19 |
1; |
|
20 |
|
|
21 |
__END__ |
|
22 |
|
|
23 |
=encoding utf8 |
|
24 |
|
|
25 |
=head1 NAME |
|
26 |
|
|
27 |
SL::Helpers::DateTime - helper functions for L<DateTime> |
|
28 |
|
|
29 |
=head1 FUNCTIONS |
|
30 |
|
|
31 |
=over 4 |
|
32 |
|
|
33 |
=item C<now_local> |
|
34 |
|
|
35 |
Returns the current time with the time zone set to the local time zone. |
|
36 |
|
|
37 |
=item C<today_local> |
|
38 |
|
|
39 |
Returns the current date with the time zone set to the local time zone. |
|
40 |
|
|
41 |
=item C<to_lxoffice> |
|
42 |
|
|
43 |
Formats the date according to the current Lx-Office user's date |
|
44 |
format. |
|
45 |
|
|
46 |
=item C<from_lxoffice> |
|
47 |
|
|
48 |
Parses a date string formatted in the current Lx-Office user's date |
|
49 |
format and returns an instance of L<DateTime>. |
|
50 |
|
|
51 |
=back |
|
52 |
|
|
53 |
=head1 AUTHOR |
|
54 |
|
|
55 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
56 |
|
|
57 |
=cut |
SL/Locale.pm | ||
---|---|---|
497 | 497 |
$myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat}; |
498 | 498 |
} |
499 | 499 |
|
500 |
sub get_local_time_zone { |
|
501 |
my $self = shift; |
|
502 |
$self->{local_time_zone} ||= DateTime::TimeZone->new(name => 'local'); |
|
503 |
return $self->{local_time_zone}; |
|
504 |
} |
|
505 |
|
|
500 | 506 |
1; |
scripts/console | ||
---|---|---|
39 | 39 |
|
40 | 40 |
use utf8; |
41 | 41 |
use CGI qw( -no_xhtml); |
42 |
use DateTime; |
|
42 | 43 |
use SL::Auth; |
43 | 44 |
use SL::Form; |
45 |
use SL::Helper::DateTime; |
|
44 | 46 |
use SL::Locale; |
45 | 47 |
use SL::LXDebug; |
46 | 48 |
use Data::Dumper; |
Auch abrufbar als: Unified diff
Hilfsfunktionen in DateTime
Conflicts: