From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 30 01:25:13 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B353FD3E for ; Thu, 30 Oct 2014 01:25:13 +0000 (UTC) Received: from mail-qc0-x231.google.com (mail-qc0-x231.google.com [IPv6:2607:f8b0:400d:c01::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C6817BE for ; Thu, 30 Oct 2014 01:25:13 +0000 (UTC) Received: by mail-qc0-f177.google.com with SMTP id l6so3385520qcy.8 for ; Wed, 29 Oct 2014 18:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:mime-version:in-reply-to:content-type :content-transfer-encoding:message-id:cc:from:subject:date:to; bh=oADfy4BhS/gCFXZ4U1BtFDRkKeJEttppy5mSxVbEQMI=; b=PVSYCVyYOw5Me0s0FrQ2IxjaMO7oMEigvBN9dRlvW3wyMP6+wDZdBzB0qQ4JPVta/A bSVxphOU5jvYadFEtChbdwEmC7r6l8PCGVdDg51GY2YFK8c2+8KKL+YiHAlIh+WY/Osv /3PONGKmvbRVzFWGtpRHOxWQdKD+7ekBRupvlubZFnOIulT4kqBx/6JZIETUjyNvHLmc 73d0f3JG9q8O932UsTVNFfAB5Ej1B2Shq4dW9OuRmtBHOlhOTMN8WyIZPRzfeuluFpPe jnmif2wx/gBUqOyjnPHYBJZBPjY738YMndXx22X7Y4Pldpzq8+M9Gk0q01Bvi0pPFBC6 my+g== X-Received: by 10.140.81.210 with SMTP id f76mr20343297qgd.60.1414632312558; Wed, 29 Oct 2014 18:25:12 -0700 (PDT) Received: from [192.168.1.14] (h68.79.89.75.dynamic.ip.windstream.net. [75.89.79.68]) by mx.google.com with ESMTPSA id 40sm3847816qgi.47.2014.10.29.18.25.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 18:25:12 -0700 (PDT) References: <4EA9EE9C-5049-4C50-B361-07F58FA19896@langille.org> <310ADD44-3897-44F6-8D82-49AD66011FFA@langille.org> Mime-Version: 1.0 (1.0) In-Reply-To: <310ADD44-3897-44F6-8D82-49AD66011FFA@langille.org> Message-Id: X-Mailer: iPhone Mail (12B411) From: "B. Estrade" Subject: Re: perl isvaliddate function Date: Wed, 29 Oct 2014 20:25:09 -0500 To: Dan Langille Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 01:25:13 -0000 It was the very least I could do. All the thanks really goes to YOU :) Cheers, Brett Sent from my iPhone > On Oct 29, 2014, at 6:34 PM, Dan Langille wrote: >=20 > Thank you. This is now in use at http://dev.freshports.org and will move t= o production later. >=20 >> On Oct 27, 2014, at 9:12 AM, B. Estrade wrote: >>=20 >> use POSIX qw/strftime/; >>=20 >> sub IsValidDate($) { >> my $string =3D shift; >> my ($year, $mon, $mday) =3D split /-/, $string; >> my $test =3D strftime("%Y-%m-%d", 0, 0, 0, $mday, $mon - 1, $year - 190= 0); >> return ($test eq $string) ? $string : undef; >> } >>=20 >> my $a =3D '2014-11-30 unless *coin ports remain unfixed'; >>=20 >> if (IsValidDate($a)) { >> print "'$a' is a valid date\n"; >> } else { >> print "'$a' is NOT a valid date\n"; >> } >>=20 >> my $b =3D '2014-02-30'; >>=20 >> if (IsValidDate($b)) { >> print "'$b' is a valid date\n"; >> } else { >> print "'$b' is NOT a valid date\n"; >> } >>=20 >> my $c =3D '2014-02-28'; >>=20 >> if (IsValidDate($c)) { >> print "'$c' is a valid date\n"; >> } else { >> print "'$c' is NOT a valid date\n"; >> } >>=20 >>=20 >>> On Sat, Oct 25, 2014 at 2:50 PM, Dan Langille wrote: >>> On Oct 25, 2014, at 2:21 PM, B. Estrade wrote: >>>=20 >>> > Looks fine to just get it working. If you wanted to be more efficient,= I believe there is a way to use the core POSIX::strfmtime in a way that wou= ld verify that the date you start with is the same date as the one returned a= fter the format. This core function is also very useful for date addition a= nd subtraction. >>> > >>> > I don't have time at this moment to create a proof of concept, but if y= ou're interested let me know and I will when I have a minute. >>>=20 >>> Yes, please, when you have time, please try that proof for me. I would a= ppreciate that. >>>=20 >>> FYI: I believe all dates within the ports tree must be YYYY-MM-DD so usi= ng something like that would be useful. >>>=20 >>> Comparing the starting date to the supplied date is good too, to catch e= dge cases like the first example. >>>=20 >>> =E2=80=94 >>> Dan Langille >=20 > =E2=80=94=20 > Dan Langille >=20