Date Stamp |
|
|
On LinkPattern, DaveSmith talked about adding digits to the link pattern.
ChrisGarrod hacked the following code together on his experimental wiki. Using a single number to represent any point on the timeline made him year10k
compliant years ago: http://igpp.ucsd.edu/~garrod/y10k/!
A DateStamp uses our current calendar, right now in SanDiego, it's 20030927.1358 -- That's all the digits of accuracy I can see from where I sit. The code below is ?IlliterateProgramming, it recognizes dates only between 1900 and 2000. Some times can be misrecognized as DateStamps. It also allows for every year to have a February 29th. Is there an elegant way to correct for leap year? $digit="[0-9]"; $sixty="[0-5]$digit"; # leap seconds ignored $seconds="$sixty$digit*"; # seconds to any precision $hours="[01]$digit|2[0-3]"; # 0..23 $time="$hours($sixty($seconds)?)?"; $AndTime=".$time"; $ohTwo="[0-2]"; $twelve="(0$digit|1$ohTwo)"; # allow month 00 and day 00 reasons later $twentynine="($twelve)$ohTwo$digit"; # all months can sometimes have 29 $thirty="(0[13-9]|1$ohTwo)30"; # except February $thirtyone="(0[13578]|1[02])31"; # and most have 31 $MonthDays="($twentynine|$thirty|$thirtyone)"; #mmdd $RecentYear="(19|20)$digit$digit"; $DateStamp="$RecentYear($twelve|$MonthDays($AndTime)?)?"; $linkWord = "[A-Z][a-z]+"; $Acronyms="[A-Z]{3,4}"; $LinkPattern = "$Acronyms|($linkWord)*$RecentYear|($linkWord)*$DateStamp|($linkWord){2,20}";I have improved this pattern several times over the past year or so, but have failed to create a sufficient suite of UnitTests -- add a few here as examples please -- ChrisGarrod -- 20030927, I have gone back to awk, it is almost always in the same place across a wide variety of unix clones.
|
Last edited September 27, 2003 Return to WelcomeVisitors |