Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.file.getArchiveFileDate
on getArchiveFileDate (f, adrDate) {
<<Changes
<<1/5/02; 4:57:55 PM by JES
<<Created.
<<Given the path to a file on disk, store the date for the archive file in the variable specified by adrDate.
<<Returns true if the date could be determined, or false if not.
<<Parameters
<<f -- the path to a file on disk
<<adrDate -- the address of a variable in which to store the archive file's date
on isNumeric (s) {
<<return true if all chars in s are numeric
local (ch, ct = sizeOf (s));
for i = 1 to ct {
ch = s[i];
if not string.isNumeric (ch) {
return (false)}};
return (true)};
local (pc = file.getPathChar ());
local (day = string.popSuffix (file.fileFromPath (f)));
if isNumeric (day) {
day = number (day);
if day > 0 and day < 32 {
local (monthFolder = file.folderFromPath (f));
local (month = string.popSuffix (file.fileFromPath (monthFolder), pc));
if isNumeric (month) {
month = number (month);
if month > 0 and month < 13 {
local (yearFolder = file.folderFromPath (monthFolder));
local (year = string.popSuffix (file.fileFromPath (yearFolder), pc));
if isNumeric (year) {
year = number (year);
if year > 1903 { //1-1-1904 is the earliest date Frontier knows about
adrDate^ = date.set (day, month, year, 0, 0, 0);
return (true)}}}}}};
return (false)}
<<bundle //test code
<<local (f, pc = file.getPathChar ())
<<f = user.radio.prefs.wwwFolder + "2002" + pc + "01" + pc + "04.txt"
<<local (d)
<<getArchiveFileDate (f, @d)
<<dialog.notify (d)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.