1 # Copyright 2005-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: future.oc,v 1.5 2007-03-30 23:40:48 pajamian Exp $
10 CodeDef future OrderCheck 1
11 CodeDef future Description Future date
12 CodeDef future Routine <<EOR
14 my($ref, $name, $value, $code) = @_;
17 my @code = Text::ParseWords::shellwords($code);
18 if($code =~ /(["']).+?\1$/) {
19 $message = pop(@code);
21 my $adjust = join " ", @code;
24 "Date must be in the future at least %s",
29 $value = Vend::Interpolate::filter_value(
34 my $current = Vend::Interpolate::mvtime(
36 { adjust => $adjust },
40 # reject invalid dates
41 if($value !~ /^[12]\d\d\d[01]\d[0123]\d(?:[0-2]\d[0-5]\d(?:[0-5]\d)?)?$/) {
42 return (0, $name, $message);
45 if($value lt $current) {
46 return (0, $name, $message);
48 return (1, $name, '');