[interchange-cvs] interchange - heins modified lib/Vend/Order.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Sat Sep 7 14:43:00 2002
User: heins
Date: 2002-09-07 18:42:48 GMT
Modified: lib/Vend Order.pm
Log:
* Add "future" comparator so that you can do:
appointment_date=3Dfuture 1 day "Sorry, we need some lead time."
That allows you to check that a date value (ala the date widget) is
in the future.
Revision Changes Path
2.30 +34 -3 interchange/lib/Vend/Order.pm
rev 2.30, prev_rev 2.29
Index: Order.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.29
retrieving revision 2.30
diff -u -r2.29 -r2.30
--- Order.pm 28 Jul 2002 05:17:03 -0000 2.29
+++ Order.pm 7 Sep 2002 18:42:47 -0000 2.30
@@ -1,6 +1,6 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.29 2002/07/28 05:17:03 mheins Exp $
+# $Id: Order.pm,v 2.30 2002/09/07 18:42:47 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -28,7 +28,7 @@
package Vend::Order;
require Exporter;
=20
-$VERSION =3D substr(q$Revision: 2.29 $, 10);
+$VERSION =3D substr(q$Revision: 2.30 $, 10);
=20
@ISA =3D qw(Exporter);
=20
@@ -210,8 +210,39 @@
my $msg =3D errmsg("%s set failed.", $var);
return ($value, $var, $msg);
},
-);
+ future =3D> sub {
+ my($name, $value, $code) =3D @_;
+ my $message;
=20
+ my @code =3D Text::ParseWords::shellwords($code);
+ if($code =3D~ /(["']).+?\1$/) {
+ $message =3D pop(@code);
+ }
+ my $adjust =3D join " ", @code;
+ if(! $message) {
+ $message =3D errmsg(
+ "Date must be in the future at least %s",
+ $adjust,
+ );
+ }
+ if($value =3D~ /\0/) {
+ $value =3D Vend::Interpolate::filter_value(
+ 'date_change',
+ $value,
+ );
+ }
+ my $current =3D Vend::Interpolate::mvtime(
+ undef,
+ { adjust =3D> $adjust },
+ "%Y%m%d%H%M",
+ );
+#::logDebug("current time: $current input value=3D$value");
+ if($value lt $current) {
+ return (0, $name, $message);
+ }
+ return (1, $name, '');
+ },
+);
=20
sub _update {
$Update =3D is_yes($_[1]);