Date & Time Conversions on VM 
Author Message
 Date & Time Conversions on VM

Has anyone developed a REXX extension that converts from one REXX Date and/or
Time format to another? I'm looking for a routine that will accept any date
and time in any of the formats returned by Date() and Time() and convert
them to any other format. I know before there was REXX (in the SEPP/BSEPP
days - boy do I feel old) there was a IPO routine called EXECSERV thatt
did some of that (including addition and subtraction of dates) but I would
like a REXX type function instead.

Also, is there anyone out there that is running VM/SP5 and has the REXX
compiler? I think the compiler was available before support for SP5 was
dropped but will the latest compiler run on SP5? If not does anyone know
how to get a copy of an SP5 compatable version? If I find one what are the
implications of licensing a product not supported or distributed by IBM?

Thanks in advance for any help.

---------------------------------------------------------------------
Dennis Putnam
Huntsville, AL



Sat, 06 Dec 1997 03:00:00 GMT  
 Date & Time Conversions on VM

Quote:

> Has anyone developed a REXX extension that converts from one REXX Date and/or
> Time format to another? I'm looking for a routine that will accept any date
> and time in any of the formats returned by Date() and Time() and convert
> them to any other format. I know before there was REXX (in the SEPP/BSEPP
> days - boy do I feel old) there was a IPO routine called EXECSERV thatt
> did some of that (including addition and subtraction of dates) but I would
> like a REXX type function instead.

Quercus's Personal Rexx has exactly that extension as

  DateInNewFormat = dateconv( DateInOldFormat, OldDateFormat, NewDateFormat )

where formats are the arg values to date(); there's no timeconv however.

Yours, Patrick
_____________________________________________________________________________


I tend to eat my UUCP feed once a day so replies can take two days



Sun, 07 Dec 1997 03:00:00 GMT  
 Date & Time Conversions on VM

Quote:

>Has anyone developed a REXX extension that converts from one REXX Date and/or
>Time format to another? I'm looking for a routine that will accept any date
>and time in any of the formats returned by Date() and Time() and convert
>them to any other format.

There is EDATE2 and my DATECALC. Both are written in REXX, and of
course I like mine better. Neither does time based stuff, but that is
probably very trivial (so he says without even knowing what the other
formats of time REXX puts out).

------------
Scott Mattes
I-Net, Inc

All rights reserved, no warrenty expressed or implied, void
where prohibited by law. My mileage varies.



Mon, 08 Dec 1997 03:00:00 GMT  
 Date & Time Conversions on VM

Quote:
> Has anyone developed a REXX extension that converts from one REXX Date and/or
> Time format to another? I'm looking for a routine that will accept any date
> and time in any of the formats returned by Date() and Time() and convert
> them to any other format.

There are several date-conversion functions available on VMSHARE.  Check
out the following files there, which contain code and discussions of the
topic.  At least one of these actually modifies the REXX interpreter source
to add a DATECONV() function!

Filename      Title
------------- --------------
MEMO RXDATE   The REXX date conversion routine of my dreams ...
MEMO DATECALC Another date calculation routine, also provides holidays, etc
MEMO EDATE2   Questions, answers, and how-to's of EDATE the second
MEMO DATEROUT Date processing packages
MEMO DATELRED Need to save the date-last-read as well as the date-created.
MEMO DATES    Discussions on Calendars, Dates, Times and Clock.
MEMO DATEC    Source code now in NOTE DATEC

PROB EDATE2   Errors encountered with the EDATE2 Rexx function
PROB EDATE    Small problem with EDATE for old users.

NOTE XDATE    XDATE EXEC -- date conversion routine, and some EXECs to test it.
NOTE EDATE2   /* Rexx function for date conversion and arithmetic, range
 0001-9999.
NOTE DATECALC REXX function to do date math and conversions
NOTE DATECNV3 Pope Gregorius said: Only centuries multiples of 400 are leap
 years.
NOTE DATECNV2 Mod to Rexx interpreter (DMSRFN) to add builtin DATECONV function.
NOTE DATEC    REXX function: Date conversion/calculations accross century
 boundaries
NOTE JDATE    /* yet another way to compute yyddd from mm/dd/yy   */
NOTE DATECONV  /*  REXX Function DATECONV for Date Conversion

Ross Patterson
Sterling Software, Inc.
VM Software Division



Mon, 08 Dec 1997 03:00:00 GMT  
 Date & Time Conversions on VM
In-Reply-To:  Ross_Patterson AT STERLING.COM -- Thu, 22 Jun 1995 09:51:31 EDT

Quote:

>(... 4 lines deleted)

>There are several date-conversion functions available on VMSHARE.  Check
>out the following files there, which contain code and discussions of the
>topic.  At least one of these actually modifies the REXX interpreter source
>to add a DATECONV() function!

>  SNIP

I thank all that reponded to my question about a Rexx date conversion
function. I found what I needed and then some. However no one has yet
responded to my question about the Rexx compiler on VM/SP5. Do I that
that to mean there are no poor folks out there that are still stuck with
SP5? Or is it that any SP5 users don't care about a Rexx compiler?

---------------------------------------------------------------------
Dennis Putnam
Huntsville, AL



Mon, 08 Dec 1997 03:00:00 GMT  
 Date & Time Conversions on VM

Quote:
> I'm looking for a routine that will accept any date and time in any of
> the formats returned by Date() and Time() and convert them to any other
> format.

 These are the "definitions", from the proposed ANSI REXX document, of the
 DATE, TIME and supporting functions.  In this ANSI REXX, they also accept
 the additional parameters to do the format changes.  They are _NOT_
 directly runable REXX code, but they have all the right logic and "magic
 numbers" needed.  You can strip out just the conversion routines.

 #Variable_Names in here are "system supplied", they have to be suitably
 converted to some REXX variable or function.  E.g., use " Arg(3, 'E') "
 for " #Bif_ArgExists.3 ".

 "CheckArgs" does just that -rigorously-, you will need to test as
 appropriate for your situation.  "Raise" causes a REXX error and does not
 return, you will need to handle these some way -maybe by just leaving
 RAISE undefined, that will stop it!

 Extracted quotes:

Caution:  This is a proposed American National Standard of Accredited
Standards Committee X3.  As such, this is not a complete standard.  The
X3J18 Technical Committee may modify this document as a result of
comments received prior to its approval as a standard.

American National Standard for Information Systems "Programming Language
REXX" ANSI X3J18-199X

9.8.1 DATE

DATE with fewer than two arguments returns the local date.  Otherwise it
converts the second argument (which has a format given by the third
argument) to the format specified by the first argument.

    call CheckArgs 'oBDEMNOSUW oANY oBDENOSU'
    /* If the third argument is given then the second is mandatory. */
    if #Bif_ArgExists.3 & \#Bif_ArgExists.2 then
      call Raise 40.19, '', #Bif_Arg.3
    if #Bif_ArgExists.1 then Option = #Bif_Arg.1
                        else Option = 'N'
    /* The date/time is 'frozen' throughout a clause. */
    if #ClauseTime.#Level == '' then do
      #Response = Config_Time()
      #ClauseTime.#Level = #Time
      #ClauseLocal.#Level = #Time + #Adjust
      end
    /* English spellings are used, even if messages not in English are used. */
    Months = 'January February March April May June July',
             'August September October November December'
    WeekDays = 'Monday Tuesday Wednesday Thursday Friday Saturday Sunday'
    /* If there is no second argument, the current date is returned. */
    if \#Bif_ArgExists.2 then
      return DateFormat(#ClauseLocal.#Level, Option)
    /* If there is a second argument it provides the date to be
    converted. */
    Value = #Bif_Arg.2
    if #Bif_ArgExists.3 then InOption = #Bif_Arg.3
                        else InOption = 'N'
    /* First try for Year Month Day */
    Logic = 'NS'
    select
      when InOption == 'N' then do
        parse var Value Day MonthIs Year
        do Month = 1 to 12
          if left(word(Months, Month), 3) == MonthIs then leave
          end Month
        end
      when InOption == 'S' then parse var Value Year +4 Month +2 Day
      otherwise Logic = 'EOU' /* or BD */
      end
    /* Next try for year without century */
    if logic = 'EOU' then
    Select
      when InOption == 'E' then parse var Value Day '/' Month '/' YY
      when InOption == 'O' then parse var Value YY '/' Month '/' Day
      when InOption == 'U' then parse var Value Month '/' Day '/' YY
      otherwise Logic = 'BD'
      end
    if Logic = 'EOU' then do
      /* The century is assumed, on the basis of the current year. */
      if \datatype(YY,'W') then
        call Raise 40.19, Value, InOption
      parse value Time2Date(#ClauseLocal.#Level) with YearNow .
      Year = YY
      do while Year < YearNow-50
        Year = Year + 100
        end
      end /* Century assumption */
    if Logic \= 'BD' then do
      /* Convert Month & Day to Days of year. */
      if \datatype(Month,'W') | \datatype(Day,'W') | \datatype(Year,'W') then
        call Raise 40.19, Value, InOption
      Days = word('0 31 59 90 120 151 181 212 243 273 304 334',Month) +,
        (Month>2)*Leap(Year) + Day-1
      end
    else
      if \datatype(Value,'W') then
        call Raise 40.19, Value, InOption
    if InOption == 'D' then do
      parse value Time2Date(#ClauseLocal.#Level) with Year .
      Days = Value - 1 /* 'D' includes current day */
      end
    /* Convert to BaseDays */
    if InOption \== 'B' then
      BaseDays = (Year-1)*365 + (Year-1)%4 - (Year-1)%100 + (Year-1)%400,
                 + Days
    else Basedays = Value
    /* Convert to microseconds from 1900 */
    Micro = BaseDays * 86400 * 1000000 - 59926608000000000
    /* Reconvert to check the original. (eg for Month = 99) */
    if DateFormat(Micro,InOption) \== Value then
      call Raise 40.19, Value, InOption
    return DateFormat(Micro, Option)
    end /* Conversion */

  DateFormat:
    /* Convert from microseconds to given format. */
    parse value Time2Date(arg(1)) with,
         Year Month Day Hour Minute Second Microsecond Base Days
    select
      when arg(2) == 'B' then
        return Base
      when arg(2) == 'D' then
        return Days
      when arg(2) == 'E' then
        return right(Day,2,'0')'/'right(Month,2,'0')'/'right(Year,2,'0')
      when arg(2) == 'M' then
        return word(Months,Month)
      when arg(2) == 'N' then
        return Day left(word(Months,Month),3) right(Year,4,'0')
      when arg(2) == 'O' then
        return right(Year,2,'0')'/'right(Month,2,'0')'/'right(Day,2,'0')
      when arg(2) == 'S' then
        return right(Year,4,'0')||right(Month,2,'0')||right(Day,2,'0')
      when arg(2) == 'U' then
        return right(Month,2,'0')'/'right(Day,2,'0')'/'right(Year,2,'0')
      otherwise /* arg(2) == 'W' */
        return word(Weekdays,1+Base//7)
      end

9.8.5 TIME

TIME with less than two arguments returns the local time within the day,
or an elapsed time.

Otherwise it converts the second argument (which has a format given by
the third argument) to the format specified by the first argument.

    call CheckArgs 'oCEHLMNORS oANY oCHLMNS'
    /* If the third argument is given then the second is mandatory. */
    if #Bif_ArgExists.3 & \#Bif_ArgExists.2 then
      call Raise 40.19, '', #Bif_Arg.3
    if #Bif_ArgExists.1 then Option = #Bif_Arg.1
                        else Option = 'N'
    /* The date/time is 'frozen' throughout a clause. */
    if #ClauseTime.#Level == '' then do
       #Response = Config_Time()
       #ClauseTime.#Level = #Time
       #ClauseLocal.#Level = #Time + #Adjust
       end
    /* If there is no second argument, the current time is returned. */
    if \#Bif_ArgExists.2 then
      return TimeFormat(#ClauseLocal.#Level, Option)
    /* If there is a second argument it provides the time to be
    converted. */
    if pos(Option, 'ERO') > 0 then
      call Raise 40.29, Option
    InValue = #Bif_Arg.2
    if #Bif_ArgExists.3 then InOption = #Bif_Arg.3
                        else InOption = 'N'
    HH = 0
    MM = 0
    SS = 0
    HourAdjust = 0
    select
      when InOption == 'C' then do
        parse var InValue HH ':' . +1 MM +2 XX
        if XX == 'pm' then HourAdjust = 12
        end
      when InOption == 'H' then HH = InValue
      when InOption == 'L' | InOption == 'N' then
        parse var InValue HH ':' MM ':' SS
      when InOption == 'M' then MM = InValue
      otherwise SS = InValue
      end
    if \datatype(HH,'W') | \datatype(MM,'W') | \datatype(SS,'N') then
      call Raise 40.19, InValue, InOption
    HH = HH + HourAdjust
    /* Convert to microseconds */
    Micro = trunc((((HH * 60) + MM) * 60 + SS) * 1000000)
    /* Reconvert to check the original. (eg for hour = 99) */
    if TimeFormat(Micro,InOption) \== InValue then
      call Raise 40.19, InValue, InOption
    return TimeFormat(Micro, Option)
    end /* Conversion */
  TimeFormat:
    /* Convert from microseconds to given format. */
    parse value Time2Date(arg(1)) with,
         Year Month Day Hour Minute Second Microsecond Base Days
    select
      when arg(2) == 'C' then
         if Hour>12 then
            return Hour-12':'right(Minute,2,'0')'pm'
         else
            return Hour':'right(Minute,2,'0')'am'
      when arg(2) == 'E' | arg(2) == 'R' then do
         /* Special case first time */
         if #StartTime.#Level == '' then do
            #StartTime.#Level = #ClauseTime.#Level
            return '0'
            end
         Output = #ClauseTime.#Level-#StartTime.#Level
         if arg(2) == 'R' then
           #StartTime.#Level = #ClauseTime.#Level
         return Output * 1E-6
         end  /* E or R */
      when arg(2) == 'H' then return Hour
      when arg(2) == 'L' then
         return right(Hour,2,'0')':'right(Minute,2,'0')':'right(Second,2,'0'),
            || '.'right(Microsecond,6,'0')
      when arg(2) == 'M' then return 60*Hour+Minute
      when arg(2) == 'N' then
         return right(Hour,2,'0')':'right(Minute,2,'0')':'right(Second,2,'0')
      when arg(2) == 'O' then
         return trunc(#ClauseLocal.#Level - #ClauseTime.#Level)
      otherwise /* arg(2) == 'S' */
        return 3600*Hour+60*Minute+Second
      end

9.2.2 Date calculations

Time2Date:
   if arg(1) < 0 then
     call Raise 40.18
   if arg(1) >= 315537897600000000 then
     call Raise 40.18
   return Time2Date2(arg(1))

 Time2Date2:Procedure
   /*  Convert a timestamp to a date.
   Argument is a timestamp (the number of microseconds relative to
   0001 01 01 00:00:00.000000)
   Returns a date in the form
     year month day hour minute second microsecond base days     */
   numeric digits 18
   /* Adjust to the virtual date 0001 01 01 00:00:00.000000 */
   Time=arg(1)+59926608000000000
   Second = Time   % 1000000    ; Microsecond = Time   // 1000000
   Minute = Second %      60    ; Second      = Second //      60
   Hour   = Minute %      60    ; Minute      = Minute //      60
   Day    = Hour   %      24    ; Hour        = Hour   //      24
   /* At
...

read more »



Thu, 11 Dec 1997 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. TIME&DATE in HTML shows TIME

2. Create Time / date or Modified Time / date of a txt file

3. DOS compressed date/time into real date/time

4. convert labview date/time to excel date/time

5. Date/Time conversions

6. string to date/time conversion

7. date/time conversion

8. Date-Time/TOD clock conversion (was Re: (no subject given))

9. Date/Time Conversion

10. Conversion of date / current time to DateAndTime

11. Question: how to convert a local Date & Time to UTC Date & Time

12. Dos Date & time to clarion date & time

 

 
Powered by phpBB® Forum Software