* Re: Date Calculations in Dec Fortran
1999-03-01 5:00 Date Calculations in Dec Fortran Daniel Steinmetz
@ 1999-03-01 5:00 ` Arne Vajhøj
1999-03-01 5:00 ` Herman D. Knoble
1999-03-02 5:00 ` Pierre.Bru
2 siblings, 0 replies; 4+ messages in thread
From: Arne Vajhøj @ 1999-03-01 5:00 UTC (permalink / raw)
To: Daniel Steinmetz, avajhoej
Daniel Steinmetz wrote:
> Does anyone have routines that manipulate dates and would not mind
> sharing them ? I'm interested in subtracting a certain number of days
> from todays date (format YYYYMMDD ) and getting the result in a similar
> format.
One solution is to use the C RTL like:
integer*4 t2
structure /tm/
integer*4 tm_sec,tm_min,tm_hour,tm_mday,tm_mon,tm_year,
+ tm_wday,tm_yday,tm_isdst
endstructure
record /tm/t
integer*4 decc$mktime,decc$localtime
t.tm_year=99
t.tm_mon=2
t.tm_mday=1
t.tm_hour=0
t.tm_min=0
t.tm_sec=0
t2 = decc$mktime(t)
t2 = t2 - 67*(24*60*60)
call lib$movc3(9*4,%val(decc$localtime(t2)),t)
write(*,*) t.tm_year,t.tm_mon,t.tm_mday
end
which surprisngly works fine on VMS Alpha 6.2 !
Arne
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Date Calculations in Dec Fortran
1999-03-01 5:00 Date Calculations in Dec Fortran Daniel Steinmetz
1999-03-01 5:00 ` Arne Vajhøj
@ 1999-03-01 5:00 ` Herman D. Knoble
1999-03-02 5:00 ` Pierre.Bru
2 siblings, 0 replies; 4+ messages in thread
From: Herman D. Knoble @ 1999-03-01 5:00 UTC (permalink / raw)
Daniel, As it turns out, back in 1972, eight years before the PC,
a group of scientists published a set of date routines in the
Association for Computing Machinery publication, CACM
(Communications of the ACM). These allow date "arithmetic"
and are not affected by Y2K or any other dates in past and
future centuries. They were then, and are still, reportedly the
shortest correct date routines published in a refereed journal.
These subprograms are available with a sample driver (main)
program and proper citations in the comments at:
http://ftp.cac.psu.edu/pub/ger/fortran/hdk/datesub.for
On Mon, 01 Mar 1999 05:28:05 GMT, Daniel Steinmetz <dani@transtech.net>
wrote:
-| Daniel Steinmetz <dani@transtech.net>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Date Calculations in Dec Fortran
1999-03-01 5:00 Date Calculations in Dec Fortran Daniel Steinmetz
1999-03-01 5:00 ` Arne Vajhøj
1999-03-01 5:00 ` Herman D. Knoble
@ 1999-03-02 5:00 ` Pierre.Bru
2 siblings, 0 replies; 4+ messages in thread
From: Pierre.Bru @ 1999-03-02 5:00 UTC (permalink / raw)
I one write routines called Read_Date_Time and Write_Date_Time (in Pascal not
in Fortran) that use RTL function:
to read your date:
call lib$init_date_time_context with something like
|!Y4!MN0!D0|!H04!M0!S0!C2| as input fomat in init-string, then call
lib$convert_date_string to convert your date to OpenVMS internal format.
at this point, you can do any date/time computation available in RTL.
to write your computed date:
first call lib$init_date_time_context with |!Y4!MN0!D0|| as init-string but
for output format, then call lib$format_date_time to convert the OpenVMS
internal date format back to ascii string.
feel free to email if you want more info.
Pierre
In article <36DA2562.D3D02A6E@transtech.net>,
Daniel Steinmetz <dani@transtech.net> wrote:
> Does anyone have routines that manipulate dates and would not mind
> sharing them ? I'm interested in subtracting a certain number of days
> from todays date (format YYYYMMDD ) and getting the result in a similar
> format.
>
> Thanks in Advance
>
> Dani Steinmetz
> Dani@transtech.net
>
> System Engineer
> Transtech Systems Inc
> Miami, FL
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
^ permalink raw reply [flat|nested] 4+ messages in thread