× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



hi James,

I'm very sorry. We all learn our lessons in life, we all make mistakes and put bugs into production. In this case, it was my fault, though I didn't put this code into production, I did publish it which amounts to the same thing.

It has at least two bugs that I can point out:

D CEEUTCO PR opdesc D Hours 10I 0 D Minutes 10I 0 D Seconds 8F

This prototype is missing the "fc" parameter (the same one you see on the CEEDATM and CEELOCT APIs). That parameter is REQUIRED, and leaving it off will cause memory corruption.

Granted, it might be unused memory and therefore go unnoticed. (And this will be the most common result) But, it might also be used memory and therefore cause "unpredictable results". (Which, I suspect, is the cause of your woes)

D CEEUTCO PR opdesc
D Hours 10I 0
D Minutes 10I 0
D Seconds 8F
D fc 12a options(*omit)

When the routine is called, the extra parameter should be specified as *OMIT.

C CALLP CEEUTCO(hours: mins: junk1: *omit)

Next problem... the CEEDATM API will return the date/time string in the national language of the user who's running the program. However, the Internet E-mail standard does not allow this. The date time string is supposed to be standardized on English. Otherwise, E-mail clients have to be written to interpret dates in every conceivable language -- which isn't practical. The internal format inside the messages should always be English, and the mail client can interpret it and convert it to the reader's native language before displaying it to them.

C CALLP CEEDATM(CurTime: rfc2822: Temp: *omit) C RETURN Temp + ' ' + tz

I wrote an updated version of this routine, as follows (it has received only light testing so far, though)

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* SMTP_getTime(): Get the current date/time from the
* system clock, formatting in SMTP fashion
*
* For example: 'Mon, 15 Aug 2006 14:30:06 -0500'
*
* returns the date/time string.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P SMTP_getTime B export
D SMTP_getTime PI 31A

D CEEUTCO PR opdesc
D Hours 10I 0
D Minutes 10I 0
D Seconds 8F
D fc 12A options(*omit)

D SUNDAY C d'1899-12-31'

D junk1 s 8F
D hours s 10I 0
D mins s 10I 0
D tz_hours s 2P 0
D tz_mins s 2P 0
D tz s 5A varying

D CurTS s Z
D CurTime s 8a varying
D CurDay s 2p 0
D CurYear s 4p 0
D CurMM s 2p 0
D CurMonth s 3a varying
D TempDOW s 10i 0
D CurDOW s 3a varying

D DateString s 31a

/free

//
// Calculate the Timezone in format '+0000', for example
// CST should show up as '-0600'
//

CEEUTCO(hours: mins: junk1: *omit);
tz_hours = %abs(hours);
tz_mins = mins;

if (hours < 0);
tz = '-';
else;
tz = '+';
endif;

tz += %editc(tz_hours:'X') + %editc(tz_mins:'X');

//
// Get the current time and convert it to the format
// specified for e-mail in RFC 2822
//

CurTS = %timestamp();

CurTime = %char(%time(CurTS): *HMS:);

CurDay = %subdt(CurTS: *DAYS);
CurYear = %subdt(CurTS: *YEARS);
CurMM = %subdt(CurTS: *MONTHS);

select;
when CurMM = 1;
CurMonth = 'Jan';
when CurMM = 2;
CurMonth = 'Feb';
when CurMM = 3;
CurMonth = 'Mar';
when CurMM = 4;
CurMonth = 'Apr';
when CurMM = 5;
CurMonth = 'May';
when CurMM = 6;
CurMonth = 'Jun';
when CurMM = 7;
CurMonth = 'Jul';
when CurMM = 8;
CurMonth = 'Aug';
when CurMM = 9;
CurMonth = 'Sep';
when CurMM = 10;
CurMonth = 'Oct';
when CurMM = 11;
CurMonth = 'Nov';
when CurMM = 12;
CurMonth = 'Dec';
endsl;

TempDOW = %diff( %date(CurTS) : SUNDAY : *DAYS );
TempDOW = %rem( TempDOW : 7 );

Select;
when TempDOW = 0;
CurDOW = 'Sun';
when TempDOW = 1;
CurDOW = 'Mon';
when TempDOW = 2;
CurDOW = 'Tue';
when TempDOW = 3;
CurDOW = 'Wed';
when TempDOW = 4;
CurDOW = 'Thu';
when TempDOW = 5;
CurDOW = 'Fri';
when TempDOW = 6;
CurDOW = 'Sat';
endsl;

DateString = CurDOW + ', '
+ %editc( CurDay: 'X' ) + ' '
+ CurMonth + ' '
+ %editc( CurYear: 'X' ) + ' '
+ CurTime + ' '
+ tz;

return DateString;

/end-free
P E

Hope that helps...

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.