+ my %args = (
+ Date => 1, Time => 1,
+ @_,
+ );
+
+ my $res;
+ if ( $args{'Date'} && !$args{'Time'} ) {
+ my (undef, undef, undef, $mday, $mon, $year) =
+ $self->Localtime( 'user' );
+ $res = sprintf( '%04d%02d%02d', $year, $mon+1, $mday );
+ } elsif ( !$args{'Date'} && $args{'Time'} ) {
+ my ($sec, $min, $hour) =
+ $self->Localtime( 'utc' );
+ $res = sprintf( 'T%02d%02d%02dZ', $hour, $min, $sec );
+ } else {
+ my ($sec, $min, $hour, $mday, $mon, $year) =
+ $self->Localtime( 'utc' );
+ $res = sprintf( '%04d%02d%02dT%02d%02d%02dZ', $year, $mon+1, $mday, $hour, $min, $sec );
+ }
+ return $res;
+}
+
+# it's been added by mistake in 3.8.0
+sub iCalDate { return (shift)->iCal( Time => 0, @_ ) }
+
+sub _SplitOffset {
+ my ($self, $offset) = @_;
+ my $sign = $offset < 0? '-': '+';
+ $offset = int( (abs $offset) / 60 + 0.001 );
+ my $mins = $offset % 60;
+ my $hours = int( $offset/60 + 0.001 );
+ return $sign, $hours, $mins;
+}
+
+=head2 Timezones handling
+
+=head3 Localtime $context [$time]
+
+Takes one mandatory argument C<$context>, which determines whether
+we want "user local", "system" or "UTC" time. Also, takes optional
+argument unix C<$time>, default value is the current unix time.
+
+Returns object's date and time in the format provided by perl's
+builtin functions C<localtime> and C<gmtime> with two exceptions:
+
+1) "Year" is a four-digit year, rather than "years since 1900"
+
+2) The last element of the array returned is C<offset>, which
+represents timezone offset against C<UTC> in seconds.
+
+=cut
+
+sub Localtime
+{
+ my $self = shift;
+ my $tz = $self->Timezone(shift);
+
+ my $unix = shift || $self->Unix;
+ $unix = 0 unless $unix >= 0;