Previous Thread
Next Thread
Print Thread
xcall DATES (DTOP_DATEAFTER) #36889 21 Dec 23 12:14 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135

I have a function that increases or decreases a date by x amount of days using XCALL DATES,2

Code
LOCAL'DAYS=30
TODAY=231221
LOCAL'PURGE'DATE=FN'INCREASE'DECREASE'DATE$(TODAY,-LOCAL'DAYS)


Return 231121 correctly under 6.5.1697.1

But Returns: 200213 under 7.0.1752.0/64

Code
!
!==============================================================================
!{Increase/Decrease dates}						![035]
!==============================================================================
FUNCTION FN'INCREASE'DECREASE'DATE$(FN'DATE AS S6, FN'DAYS AS F6) AS S6
! IN:  Date in the format of YYMMDD
! IN:  Number of days.
! OUT: New Date (YYMMDD)
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
MAP1 LOCAL'RESULT,F,6
MAP1 LOCAL'DATE,S,8
MAP1 LOCAL'NEW'DATE,S,8
	FN'INCREASE'DECREASE'DATE$=FN'DATE
	IF FN'DATE<>"" THEN
	   LOCAL'DATE=FN'FORMAT'DATE$(FN'DATE)
	   XCALL DATES,2,LOCAL'RESULT,LOCAL'DATE,LOCAL'NEW'DATE,FN'DAYS
	   IF LOCAL'RESULT<>0 THEN
	      XCALL MESAG,"DATE COMPUTE ERROR "+LOCAL'RESULT+" FOR DATE "+FN'DATE,2
	     ELSE
	      FN'INCREASE'DECREASE'DATE$=LOCAL'NEW'DATE[7;2]+LOCAL'NEW'DATE[4;2]+LOCAL'NEW'DATE[1;2]
	   ENDIF
	ENDIF
	EXITFUNCTION
LOCAL'TRAP:
 	XCALL MESAG,"Function Error "+STR(ERR(0))+" in FN'INCREASE'DECREASE'DATE$",2
	RESUME ENDFUNCTION WITH_ERROR 99
ENDFUNCTION

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36890 21 Dec 23 05:01 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Hmmm....

There's a similar function in the SOSLIB:fndatetime.bsi ...
Code
Function Fn'Date'Plus'Days'To'MM'DD'YY$(flexdate$ as T_FLEX_DATE:inputonly, &
                     days as i2:inputonly) as T_MM'DD'YY

    map1 locals
        map2 mm'dd'yy$,s,8
        map2 result,f
        map2 status,f
        map2 idate,b,4
        
    ! first convert all supported formats to mm/dd/yy    
    mm'dd'yy$ = Fn'Date'To'MM'DD'YY$(flexdate$)
    
    XCALL IDTIM,mm'dd'yy$,idate,0,2,status  ! check if valid
    if status # 0 then
        .fn = "?"
    else    
        xcall DATES,DTOP_DATEAFTER,result,mm'dd'yy$,.fn,days
        debug.print (99,"fndatetime") flexdate$,mm'dd'yy$,days,.fn
        if result then
            .fn = "?"
        endif
    endif
EndFunction

I checked it on a 64 bit EL7 system and it seems to work ok, and the logic is pretty similar to yours. Can you check to see if it has the same problem on your system? I wonder if it has something to do with the locale difference (DDMMYY vs MMDDYY)?

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36891 21 Dec 23 05:07 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Do you also have the Fn'Date'To'MM'DD'YY$() at can too? Used with in Fn'Date'Plus'Days'To'MM'DD'YY$.

I was going try: PRINT Fn'Date'Plus'Days'To'MM'DD'YY$("231221",-30)

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36892 21 Dec 23 05:09 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
How about just pulling down the file from fndatetime.bsi ?

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36893 21 Dec 23 05:11 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Note that although it's intended as a ++include module, you can also compile it as a RUN with a built-in set of test routines, using:

.compil fndatetime.bsi/x:2/m/px/c:FNDATETIME_BSI_TEST=1

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36894 21 Dec 23 05:11 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
OK, Thanks I'll give that a bash in the morning, popping out shortly.

I started a DATTST.BAS in [241,551] with your function on my local linux server., But getting:
COMPIL dattst.J00/AV/X:2/PX/N
Phase 1
?Illegal type code (8) - Function Fn'Date'Plus'Days'To'MM'DD'YY$(flexdate$ as T_FLEX_DATE:inputonly,

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36895 21 Dec 23 05:24 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
This was my test program DATE1.BAS in [241,551] on my server, but will try get a working example with fndatetime.bsi tomorrow.


Code
MAP1 TODAY,S,6,231221
PRINT FN'INCREASE'DECREASE'DATE$(TODAY,-30)
END

FUNCTION FN'INCREASE'DECREASE'DATE$(FN'DATE AS S6, FN'DAYS AS F6) AS S6
! IN:  Date in the format of YYMMDD
! IN:  Number of days.
! OUT: New Date (YYMMDD)
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
MAP1 LOCAL'RESULT,F,6
MAP1 LOCAL'DATE,S,8
MAP1 LOCAL'NEW'DATE,S,8
        FN'INCREASE'DECREASE'DATE$=FN'DATE
        IF FN'DATE<>"" THEN
           LOCAL'DATE=FN'DATE[5;2]+"/"+FN'DATE[3;2]+"/"+FN'DATE[1;2]
           XCALL DATES,2,LOCAL'RESULT,LOCAL'DATE,LOCAL'NEW'DATE,FN'DAYS
           IF LOCAL'RESULT<>0 THEN
              XCALL MESAG,"DATE COMPUTE ERROR "+LOCAL'RESULT+" FOR DATE "+FN'DATE,2
             ELSE
              FN'INCREASE'DECREASE'DATE$=LOCAL'NEW'DATE[7;2]+LOCAL'NEW'DATE[4;2]+LOCAL'NEW'DATE[1
           ENDIF
        ENDIF
        EXITFUNCTION
LOCAL'TRAP:
        XCALL MESAG,"Function Error "+STR(ERR(0))+" in FN'INCREASE'DECREASE'DATE$",2
        RESUME ENDFUNCTION WITH_ERROR 99
ENDFUNCTION

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36896 21 Dec 23 05:26 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Yeah you'll either need to ++include the bsi, since it contains the deftype for T_FLEX_DATE, not to mention a bunch of other includes...
Code
++include'once ashinc:ashell.def
++include'once ashinc:ashell.sdf    ! [114]
++include'once ashinc:types.def     ! [107
++include'once ashinc:regex.def
++include'once ashinc:gtlang.sdf    ! [113]
++include'once sosfunc:fnistype.bsi
++include'once sosfunc:fndec2hex.bsi
++include'once sosfunc:fnfileage.bsi    ! [121]
++include'once sosfunc:fnextch.bsi      ! [121]
++include'once sosfunc:fndtoffset.bsi   ! [164]

deftype T_FLEX_DATE = s,50       ! [116] (see Date Format Notes above)
deftype T_FLEX_TIME = s,12       ! [121] various time formats, including "now"

Or maybe you can get away with just copying that one deftype.

Warning: once you start browsing through that module, you may end up pepper your code with all kinds of Fn'Date'xxxx() function calls. For example, I find Fn'Date'To'MM'DD'YY$(INV'DATE$) easier to type and to read than INV'DATE$[1,2]+"/"+INV'DATE$[3,4]+"/"+INV'DATE$[5,6]

Additional warning: the idea of the T_FLEX_DATE type and most of the routines in the module was to allow the passing of dates around without needing to worry too much about the format of the source date. (When integrating data to/from different sources, it can be a real pain to have to keep worry about whether a particular input date parameter is DDMMYY, or CCYYMMDD, or MM/DD/YY, or CCYY-MM-DD, or dd-mon-yr, etc. For the most part these routines can figure out the format that you pass it. There are however some ambiguous cases, like 101112 which could be YYMMDD, MMDDYY or DDMMYY. Even the current date could be a problem (231221 could be either YYMMDD or DDMMYY). So it works best with input dates that are 8 digits (CCYYMMDD) or have slashes, or dashes (CCYY-MM-DD) or use a non-ambiguous format like dd-mon-yr, etc.)

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36897 21 Dec 23 05:31 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
I'll try yours out in my environment a bit later, after you've finished your last minute shopping! (BTW I wear a 9.5 UK sock size laugh )

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36898 21 Dec 23 05:32 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
I think the Fn'Date'To'MM'DD'YY$(INV'DATE$) is similar to the FN'FORMAT'DATE$() I just removed it out the above example to get a simple test working.
Now leaving the keyboard/screen for a few hours.. smile

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36899 21 Dec 23 05:33 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Socked added to list smile its more Pipa's grandson Max is bugging and after a trip to the shop to spend some of his early xmas money.

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36901 22 Dec 23 07:26 AM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Ok, I figured out the problem, but haven't had time to properly fix it. It seems to affect only CentOS 8, where one of the semi-standard data types used in many legacy parts of the A-Shell code has a different size there than it does on other platforms. I need to go through several routines and do review / update the data types used for parameter passing. So don't waste any time in on it until I can get that done, hopefully on Friday.

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36902 22 Dec 23 09:01 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Morning, Is that being a CentOS8 32/64 bit thing? No hurry on any fix as im only running this version locally so far plus we break for xmas at midday today, Back Tuesday 2nd January.

Have a Happy Christmas & New Year everyone. smile

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36903 22 Dec 23 05:12 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
It's definitely a 32/64 bit issue, although I'm still trying to figure out exactly what's different in the CentOS 8 environment. Probably just a configuration/definition file somewhere. It's a good excuse though to go through all the source code and standardize the various type definitions to make sure they're both consistent and appropriate. Now that you've given me the rest of the holidays off, I guess I can take my time doing that thoroughly.

Enjoy the holidays and Happy New Year!

Re: xcall DATES (DTOP_DATEAFTER) [Re: Steve - Caliq] #36910 03 Jan 24 09:21 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Morning, Happy New Year...

I've finally found my keyboard again after the xmas / new year break..

I "think" version 7.0.1753.1/64 has fixed this under my CentOS 8..

Thanks.


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3