# 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: TimezoneField.pm,v 2.2 2006/10/16 21:08:05 moeller Exp $ package Bivio::UI::HTML::Widget::TimezoneField; use strict; $Bivio::UI::HTML::Widget::TimezoneField::VERSION = sprintf('%d.%02d', q$Revision: 2.2 $ =~ /\d+/g); $_ = $Bivio::UI::HTML::Widget::TimezoneField::VERSION; =head1 NAME Bivio::UI::HTML::Widget::TimezoneField - hidden field which computes Timezone =head1 RELEASE SCOPE bOP =head1 SYNOPSIS use Bivio::UI::HTML::Widget::TimezoneField; Bivio::UI::HTML::Widget::TimezoneField->render($source, $buffer); =cut =head1 EXTENDS L =cut use Bivio::UI::Widget; @Bivio::UI::HTML::Widget::TimezoneField::ISA = ('Bivio::UI::Widget'); =head1 DESCRIPTION C renders a hidden field which computes the Timezone in JavaScript. Since there is no C in JavaScript. This is a hack. Right now, we only get the delta for I. This should be sufficient for most problems. In general, we try to render dates and times on the client. =cut #=IMPORTS use Bivio::Biz::FormModel; use Bivio::UI::HTML::Widget::JavaScript; #=VARIABLES my($_FIELD) = Bivio::Biz::FormModel->TIMEZONE_FIELD; my($_FUNCS) = Bivio::UI::HTML::Widget::JavaScript->strip(<<"EOF"); function tzf(){ // Compute the timezone if(navigator.appName.indexOf('Netscape')>=0 &&parseFloat(navigator.appVersion)<4.0) // Netscape 3.01 doesn' handle inserting tags dynamically return; var d=new Date(); var o=d.getTimezoneOffset(); document.write(''); } EOF =head1 METHODS =cut =for html =head2 render(any source, string_ref buffer) =cut sub render { my($self, $source, $buffer) = @_; Bivio::UI::HTML::Widget::JavaScript->render($source, $buffer, 'tzf', $_FUNCS, "tzf();"); return; } #=PRIVATE METHODS =head1 COPYRIGHT 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 =head1 VERSION $Id: TimezoneField.pm,v 2.2 2006/10/16 21:08:05 moeller Exp $ =cut 1;