Skip to content

errors in SBLDatelib

Forums Forums SIMPOL Programming errors in SBLDatelib

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #109
    Jim Locker
    Member

    Take a look at the code for the DAYS command and compare to the string2data function. documentation does not match parameter list, and parameter list between DAYS and string2date just looks wrong. in DAYS, we have dt =@ string2data(value, format, centurybase, ldiLocale) where centurybase is an integer and ldiLocale is a SBLlocaledateinfo object, but the actual parameter list on string2date is: string t, string format, SBLlocaledateinfo datelocale, integer error I cannot make DAYS work when I try DAYS(datastring, format) and any way I try DAYS(datastring,format,centurybase) gives one of a couple different errors, depending on how I instantiate centurybase. Wrong type if I make it an integer and put 1930 in it, and error 200 if I set it with SBLlocaledateinfo.new(). I do have a segment of code like this: DAYS(DATESTR(dateobj,format),format) and that works. But I can only do that in specific circumstances.

    #1447
    Michael
    Keymaster

    jim wrote:
    > Take a look at the code for the DAYS command and compare to the
    > string2data function.
    >
    > documentation does not match parameter list, and parameter list
    > between DAYS and string2date just looks wrong.
    >
    > in DAYS, we have
    >
    > dt =@ string2data(value, format, centurybase, ldiLocale) where
    > centurybase is an integer and ldiLocale is a SBLlocaledateinfo
    > object, but the actual parameter list on string2date is:
    >
    > string t, string format, SBLlocaledateinfo datelocale, integer error
    >

    You are right. the DAYS() function was written a very long time ago and
    has not been revisited. In the interim, centurybase got moved into the
    SBLlocaledateinfo object. I have rewritten the function and it now looks
    like this:

    function DAYS(string value, string format, SBLlocaledateinfo ldiLocale,
    integer error) information "[simpol::return::integer]" export
    date dt
    integer i, e

    e = 0
    dt =@ string2date(value, format, ldiLocale, error=e)
    if dt =@= .nul
    error = e
    else
    i = dt
    if i >= SIMPOL_SEP14_1752
    i = i + (OLDSBL_SEP14_1752 – SIMPOL_SEP14_1752)
    else if i > SIMPOL_SEP02_1752
    i = OLDSBL_SEP02_1752
    else
    i = i + (OLDSBL_SEP02_1752 – SIMPOL_SEP02_1752)
    end if
    end if
    end function i

    One important thing to note here. This function was meant to be 100%
    compatible with the Superbase function. The integer value it returns is
    off for use with a SIMPOL date object. For that you should just use
    string2date() directly. It is only meant for hybrid applications where
    both Superbase and SIMPOL are working with the same data and where a
    field-level calculation may be using the DAYS() value for some reason.

    Ciao, Neil

    #1834
    Jim Locker
    Member

    I HAD read the description of the corrections made in Superbase, and I
    also had rewritten the DAYS function to work appropriately. When I did
    that, I discovered I was getting incorrect dates in Simpol. So I have
    already started using the string2date function directly.

    I won't modify your libraries; that is an excellent way to introduce weird
    bugs after upgrades.

    However, I was sure you'd want to know about this.

    #1399
    Michael
    Keymaster

    jim wrote:
    > I HAD read the description of the corrections made in Superbase, and
    > I also had rewritten the DAYS function to work appropriately. When I
    > did that, I discovered I was getting incorrect dates in Simpol. So I
    > have already started using the string2date function directly.
    >
    > I won't modify your libraries; that is an excellent way to introduce
    > weird bugs after upgrades.
    >
    > However, I was sure you'd want to know about this.

    I very much appreciate it when people let me know about these issues.
    Some of this code was written a very long time ago.

    Ciao, Neil

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.