Timestamp in REXX 
Wednesday, 15 August 2012, 14:37 - Informatica, Programmazione, Programmazione strutturata, Linguaggi, REXX
Postata da Daniels118
Questa routine consente di calcolare il timestamp in REXX, è necessario passare una data nel formato "YYYY/MM/DD hh:mm:ss" ed eventualmente un intero per modificare il timezone:

timestamp: procedure /* (date[, TZ]) */
  parse arg dt, tz
  parse var dt yy"/"mm"/"dd" "h":"m":"s
  s = (((dd - 1) * 24 + h) * 60 + m) * 60 + s
  do i = 1972 to yy - 1 by 4
    s = s + 86400                                  /* + 1 day   */
  end
  do i = 1 to mm - 1
    select
      when i = 2 then do
        if yy // 4 = 0 then s = s + 2505600        /* + 29 days */
                       else s = s + 2419200        /* + 28 days */
      end
      when i = 4 ! i = 6 ! i = 9 ! i = 11 then
        s = s + 2592000                            /* + 30 days */
      otherwise s = s + 2678400                    /* + 31 days */
    end
  end
  s = s + (yy - 1970) * 31536000           /* + years from 1970 */
  if arg(2, "E") then s = s + tz * 3600
return s



Questa funzione consente di ottenere il timestamp corrente:

now: procedure /* () */
return timestamp("20"date("O")" "time("N"))


Leggi notizia ( 214 letture )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 2.9 / 370 )


<<Prima <Indietro | 1 | 2 | 3 |