* need help using RTL time functions
@ 1994-01-05 18:20 Jerry Sy
1994-01-05 21:05 ` Neil Readwin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jerry Sy @ 1994-01-05 18:20 UTC (permalink / raw)
I am writing a simple Vax C program to calculate time difference,
but the RTL LIB$ functions does not seem to be returning to me
the correct results. can anybody tell me what I am doing wrong ?
My code is shown below. I know that the difference should be 30 minutes
but the RTL function gives me 24 minutes as the difference between
7:30 and 7:00!
please email replies if possible.
thanks in advance
JERRY
/* INCLUDE FILES */
#include stdio
#include stdlib
#include time
#include string
#include descrip
#include libdtdef
unsigned long result,operation,delta_min;
typedef struct dsc$descriptor_s desctype;
desctype dateA,dateB;
unsigned long qDateA,qDateB,qDateDiff;
static char TimeA[24],TimeB[24];
void initDesc(char* theStr,desctype* theDesc,int len);
main()
{
initDesc(TimeA,&dateA,23);
initDesc(TimeB,&dateB,23);
strcpy(TimeA,"28-DEC-1993 07:00:00.00");
strcpy(TimeB,"28-DEC-1993 07:30:00.00");
result=lib$convert_date_string(&dateB,&qDateB);
result=lib$convert_date_string(&dateA,&qDateA);
result=lib$sub_times(&qDateB,&qDateA,&qDateDiff);
operation=LIB$K_DELTA_MINUTES;
result=lib$cvt_from_internal_time(&operation,&delta_min,&qDateDiff);
}
void initDesc(char* theStr,desctype* theDesc,int len)
{
theDesc->dsc$w_length=len;
theDesc->dsc$b_dtype=DSC$K_DTYPE_T;
theDesc->dsc$b_class=DSC$K_CLASS_S;
theDesc->dsc$a_pointer=theStr;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: need help using RTL time functions
1994-01-05 18:20 need help using RTL time functions Jerry Sy
@ 1994-01-05 21:05 ` Neil Readwin
1994-01-05 21:22 ` Pat Rankin
1994-01-06 4:53 ` Carl J Lydick
2 siblings, 0 replies; 4+ messages in thread
From: Neil Readwin @ 1994-01-05 21:05 UTC (permalink / raw)
ah301@yfn.ysu.edu (Jerry Sy) writes:
|> can anybody tell me what I am doing wrong ?
Times are quadwords, not longs, so this won't work on a VAX. Try ...
#include stdlib
#include time
#include string
#include descrip
#include libdtdef
unsigned long result,operation,delta_min;
unsigned long qDateA[2],qDateB[2],qDateDiff[2];
main()
{
$DESCRIPTOR(dateA, "28-DEC-1993 07:00:00.00");
$DESCRIPTOR(dateB, "28-DEC-1993 07:30:00.00");
result=lib$convert_date_string(&dateB,&qDateB);
result=lib$convert_date_string(&dateA,&qDateA);
result=lib$sub_times(&qDateB,&qDateA,&qDateDiff);
operation=LIB$K_DELTA_MINUTES;
result=lib$cvt_from_internal_time(&operation,&delta_min,&qDateDiff);
}
--
Phone: +44 71 815 5283 E-mail: nreadwin@micrognosis.co.uk
Anything is a cause for sorrow that my mind or body has made
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: need help using RTL time functions
1994-01-05 18:20 need help using RTL time functions Jerry Sy
1994-01-05 21:05 ` Neil Readwin
@ 1994-01-05 21:22 ` Pat Rankin
1994-01-06 4:53 ` Carl J Lydick
2 siblings, 0 replies; 4+ messages in thread
From: Pat Rankin @ 1994-01-05 21:22 UTC (permalink / raw)
In article <ah301-050194132027@sy_j.pgh.wec.com>,\
ah301@yfn.ysu.edu (Jerry Sy) writes...
> I am writing a simple Vax C program to calculate time difference,
> but the RTL LIB$ functions does not seem to be returning to me
> the correct results. can anybody tell me what I am doing wrong ?
[...]
> unsigned long qDateA,qDateB,qDateDiff;
You can't make a quadword variable by prefixing the name of a
longword variable with "q". Change each of those to be arrays of two
longs (or four shorts, &c), and change the code which manipulates them
to cope with arrays rather than scalars.
unsigned long qDateA[2], qDateB[2], qDateDiff[2];
..lib$sub_times(qDateA, qDateB, qDateDiff); /* note '&'s removed */
Pat Rankin, rankin@eql.caltech.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: need help using RTL time functions
1994-01-05 18:20 need help using RTL time functions Jerry Sy
1994-01-05 21:05 ` Neil Readwin
1994-01-05 21:22 ` Pat Rankin
@ 1994-01-06 4:53 ` Carl J Lydick
2 siblings, 0 replies; 4+ messages in thread
From: Carl J Lydick @ 1994-01-06 4:53 UTC (permalink / raw)
In article <ah301-050194132027@sy_j.pgh.wec.com>, ah301@yfn.ysu.edu (Jerry Sy) writes:
=I am writing a simple Vax C program to calculate time difference,
=but the RTL LIB$ functions does not seem to be returning to me
=the correct results. can anybody tell me what I am doing wrong ?
=
=My code is shown below. I know that the difference should be 30 minutes
=but the RTL function gives me 24 minutes as the difference between
=7:30 and 7:00!
=
=please email replies if possible.
=thanks in advance
=
=JERRY
=
=
=/* INCLUDE FILES */
=#include stdio
=#include stdlib
=#include time
=#include string
=#include descrip
=#include libdtdef
=
=unsigned long result,operation,delta_min;
=typedef struct dsc$descriptor_s desctype;
=desctype dateA,dateB;
=unsigned long qDateA,qDateB,qDateDiff;
A lonwgword is two words (32 bits); a quadword is 4 words (64 bits [2
longwords]). Change this declaration to:
unsigned long qDateA[2],qDateB[2],qDateDiff[2];
and your problem will be fixed
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My
understanding of astronomy is purely at the amateur level (or below). So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it. If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1994-01-06 4:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-01-05 18:20 need help using RTL time functions Jerry Sy
1994-01-05 21:05 ` Neil Readwin
1994-01-05 21:22 ` Pat Rankin
1994-01-06 4:53 ` Carl J Lydick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox