Lx-Office heißt nun kivitendo
[kivitendo-erp.git] / SL / Helper / DateTime.pm
1 package DateTime;
2
3 use strict;
4
5 sub now_local {
6   return shift->now(time_zone => $::locale->get_local_time_zone);
7 }
8
9 sub today_local {
10   return shift->now(time_zone => $::locale->get_local_time_zone)->truncate(to => 'day');
11 }
12
13 sub to_lxoffice {
14   my $self   = shift;
15   my %params = (scalar(@_) == 1) && (ref($_[0]) eq 'HASH') ? %{ $_[0] } : @_;
16   return $::locale->format_date_object($self, %params);
17 }
18
19 sub from_lxoffice {
20   return $::locale->parse_date_to_object(\%::myconfig, $_[1]);
21 }
22
23 1;
24
25 __END__
26
27 =encoding utf8
28
29 =head1 NAME
30
31 SL::Helpers::DateTime - helper functions for L<DateTime>
32
33 =head1 FUNCTIONS
34
35 =over 4
36
37 =item C<now_local>
38
39 Returns the current time with the time zone set to the local time zone.
40
41 =item C<today_local>
42
43 Returns the current date with the time zone set to the local time zone.
44
45 =item C<to_lxoffice %param>
46
47 Formats the date and time according to the current kivitendo user's
48 date format with L<Locale::format_datetime_object>.
49
50 =item C<from_lxoffice $string>
51
52 Parses a date string formatted in the current kivitendo user's date
53 format and returns an instance of L<DateTime>.
54
55 Note that only dates can be parsed at the moment, not the time
56 component (as opposed to L<to_lxoffice>).
57
58 =back
59
60 =head1 AUTHOR
61
62 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
63
64 =cut