# Copyright (c) 1999-2001 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: Date.pm,v 2.2 2010/11/01 22:09:51 moeller Exp $ package Bivio::UI::HTML::Format::Date; use strict; use Bivio::Base 'UIHTML.Format'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.2 $ =~ /\d+/g); my($_DT) = b_use('Type.DateTime'); sub get_widget_value { # Formats a date time value as a string with the # specified 2 or 4 digit year. my(undef, $time, $year_digits) = @_; return '' unless defined($time); b_die('invalid year_digits ', $year_digits) if defined($year_digits) && $year_digits != 2 && $year_digits != 4; $year_digits ||= 4; my($sec, $min, $hour, $mday, $mon, $year) = $_DT->to_parts($time); return $year_digits == 2 ? sprintf('%02d/%02d/%02d', $mon, $mday, $year =~ /(\d\d)$/) : sprintf('%02d/%02d/%04d', $mon, $mday, $year); } 1;