Forums › Forums › SIMPOL Programming › errors in SBLDatelib
- This topic has 3 replies, 2 voices, and was last updated 14 years, 3 months ago by Jim Locker.
- AuthorPosts
- February 4, 2010 at 12:54 am #109Jim LockerMember
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.
February 10, 2010 at 10:40 am #1447MichaelKeymasterjim 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, ee = 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 iOne 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
February 11, 2010 at 4:17 pm #1834Jim LockerMemberI 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.
February 16, 2010 at 5:02 pm #1399MichaelKeymasterjim 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
- AuthorPosts
- You must be logged in to reply to this topic.