Script

Show Script

Showing code for: includes/moddate.irev

Back

<?rev

   -- iRev include file
   -- shows the modification date of the current page

   -- get the path to the page just loaded
   put $_SERVER["PATH_TRANSLATED"] into tPath

   -- use the ls shell command to get the details for this file
   put shell("ls -l " & quote & tPath & quote) into tListing
   put line 1 of tListing into tFileData

   -- remove the excess data
   delete word 1 to 5 of tFileData
   replace tPath with empty in tFileData

   -- date now reads:
   -- month day hh:mm (using 24 hour time)
   -- or
   -- month day year

   -- break the date up into it's components
   put empty into tYear
   put word 1 of tFileData into tMonth
   put word 2 of tFileData into tDay
   put word 3 of tFileData into tHour
   if tHour contains ":" is false then
      put tHour into tYear
      put empty into tHour
      put empty into tMins
   else
      set the itemDel to ":"
      put item 2 of tHour into tMins
      put item 1 of tHour into tHour
   end if
   
   -- get the month number
   put lineOffset(tMonth, the monthNames) into tMonthNum
   if tMonthNum = 0 then
      put lineOffset(tMonth, the abbrev monthNames) into tMonthNum
      if tMonthNum = 0 then
         put empty into tMonthNum
      end if
   end if
   
   -- assemble into dateItems format
   set the itemDel to comma
   put the seconds into tDate
   convert tDate to dateItems
   if tYear is not empty then
      put tYear into item 1 of tDate
   end if
   if tMonthNum is not empty then
      put tMonthNum into item 2 of tDate
   end if
   if tDay is not empty then
      put tDay into item 3 of tDate
   end if
   if tHour is not empty then
      put tHour into item 4 of tDate
   else
      -- use 12 midday of there is no time, as this avoids any daylight savings confusion around midnight
      put 12 into item 4 of tDate
   end if
   if tMins is not empty then
      put tMins into item 5 of tDate
   else
      put 0 into item 5 of tDate
   end if
   put 0 into item 6 of tDate
   
   -- now convert into an appropriate format
   if tHour is empty then
      -- date only
      convert tDate to long date
   else
      convert tDate to internet date  -- long date and short time
   end if
   
   -- format the display (this uses the function from includes/time.irev but is replicated
   -- here to avoid any possible nested includes)
   
   put "<p><font size='-2'>This script was last modified on: " & tDate into tRes
   -- put " (" & tPath & ")</font></p>" after tRes

   put "+1000" into tLocalZone
   
   put last word of tDate into tServerZone
   put tLocalZone - tServerZone into tHoursDiff
   put char -2 to -1 of tHoursDiff into tMinsDiff
   if char 1 of tHoursDiff = "-" then put "-" before tMinsDiff
   delete char -2 to -1 of tHoursDiff
       
   put tDate into tLocalTime
   convert tLocalTime to dateItems
   set the itemDel to comma
   add tHoursDiff to item 4 of tLocalTime
   add tMinsDiff to item 3 of tLocalTime
   convert tLocalTime to internet date
   put tLocalZone into last word of tLocalTime
   put " (Local time: " & tLocalTime & ")" after tRes

   put "</font></p>" after tRes

   -- this include file displays the mod date directly
   put tRes