DateTime::to_kivitendo_time: Formatierung eines DateTimes als Zeit
[kivitendo-erp.git] / SL / Helper / DateTime.pm
1 package DateTime;
2
3 use strict;
4
5 use SL::Util qw(_hashify);
6
7 sub now_local {
8   return shift->now(time_zone => $::locale->get_local_time_zone);
9 }
10
11 sub today_local {
12   return shift->now(time_zone => $::locale->get_local_time_zone)->truncate(to => 'day');
13 }
14
15 sub to_kivitendo_time {
16   my ($self, %params) = _hashify(1, @_);
17   return $::locale->format_date_object_to_time($self, %params);
18 }
19
20 sub to_kivitendo {
21   my ($self, %params) = _hashify(1, @_);
22   return $::locale->format_date_object($self, %params);
23 }
24
25 sub to_lxoffice {
26   # Legacy name.
27   goto &to_kivitendo;
28 }
29
30 sub from_kivitendo {
31   return $::locale->parse_date_to_object(\%::myconfig, $_[1]);
32 }
33
34 sub from_lxoffice {
35   # Legacy name.
36   goto &from_kivitendo;
37 }
38
39 1;
40
41 __END__
42
43 =encoding utf8
44
45 =head1 NAME
46
47 SL::Helpers::DateTime - helper functions for L<DateTime>
48
49 =head1 FUNCTIONS
50
51 =over 4
52
53 =item C<now_local>
54
55 Returns the current time with the time zone set to the local time zone.
56
57 =item C<today_local>
58
59 Returns the current date with the time zone set to the local time zone.
60
61 =item C<to_kivitendo %param>
62
63 Formats the date and time according to the current kivitendo user's
64 date format with L<Locale::format_datetime_object>.
65
66 The legacy name C<to_lxoffice> is still supported.
67
68 =item C<from_kivitendo $string>
69
70 Parses a date string formatted in the current kivitendo user's date
71 format and returns an instance of L<DateTime>.
72
73 Note that only dates can be parsed at the moment, not the time
74 component (as opposed to L<to_kivitendo>).
75
76 The legacy name C<from_lxoffice> is still supported.
77
78 =back
79
80 =head1 AUTHOR
81
82 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
83
84 =cut