# Copyright (c) 2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: DateTimeWithTimeZone.pm,v 1.2 2010/01/25 03:15:10 nagler Exp $ package Bivio::Type::DateTimeWithTimeZone; use strict; use Bivio::Base 'Bivio.Type'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.2 $ =~ /\d+/g); my($_IDI) = __PACKAGE__->instance_data_index; my($_DT) = b_use('Type.DateTime'); sub as_date_time { my($self) = @_; my($fields) = $self->[$_IDI]; return $fields->{tz}->date_time_from_utc($fields->{dt}); } sub as_literal { my($self) = @_; return substr($_DT->to_string($self->as_date_time, 0), 0, -3); } sub from_literal { b_die('not supported yet'); # DOES NOT RETURN } sub new { my($proto, $date_time, $time_zone) = @_; my($self) = shift->SUPER::new; $self->[$_IDI] = { tz => $time_zone, dt => $date_time, }; return $self; } sub to_literal { my(undef, $value) = @_; return '' unless $value; return $value->as_literal; } 1;