lasso 8.5 date bug - any workarounds

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

lasso 8.5 date bug - any workarounds

Tami Williams
Has anyone already created a workaround for this problem in Lasso 8.5.


If you do this:

<p>DATE TEST [date('5/39/1980')]</p>.


You get this:
DATE TEST 1980-06-08 00:00:00



This is a problem when trying to build a date value based on user  
input of 3 parameters (day, month and year) and check that its a valid  
date.

valid_date says that the date is VALID even when its not.





This:

<p>DATE TEST [date('5/39/1980')]</p>

[var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']

<p>[date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear))]</
p>

<p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',  
$dobDay, '/', $dobYear)))]</p>



Outputs this:

DATE TEST 1980-06-08 00:00:00

1980-06-08 00:00:00

Valid date true




Has someone already built a custom tag/workaround for this?  Thanks in  
advance.








#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

stevepiercy
valid_date('5/39/1980', -format='%-D');

=> false

For UI, try the lovely jQuery datepicker with validate.  It is
skinnable with jQueryUI skins.
http://keith-wood.name/datepick.html
http://plugins.jquery.com/project/validate

Working example (also includes time picker):
http://www.d2sra.org/forms/sendoff/

--steve


On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:

>Has anyone already created a workaround for this problem in Lasso 8.5.
>
>
>If you do this:
>
><p>DATE TEST [date('5/39/1980')]</p>.
>
>
>You get this:
>DATE TEST 1980-06-08 00:00:00
>
>
>
>This is a problem when trying to build a date value based on
>user input of 3 parameters (day, month and year) and check that
>its a valid date.
>
>valid_date says that the date is VALID even when its not.
>
>
>
>
>
>This:
>
><p>DATE TEST [date('5/39/1980')]</p>
>
>[var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>
><p>[date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear))]</p>
>
><p>Valid date [valid_date(date(string_concatenate($dobMonth,
>'/', $dobDay, '/', $dobYear)))]</p>
>
>
>
>Outputs this:
>
>DATE TEST 1980-06-08 00:00:00
>
>1980-06-08 00:00:00
>
>Valid date true
>
>
>
>
>Has someone already built a custom tag/workaround for this?  Thanks in advance.
>
>
>
>
>
>
>
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list <[hidden email]>.
>To unsubscribe, E-mail to: <[hidden email]>
>To switch to the DIGEST mode, E-mail to <[hidden email]>
>To switch to the INDEX mode, E-mail to <[hidden email]>
>Send administrative queries to  <[hidden email]>
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Tami Williams
Thanks!

I do usually use the jquery datepicker but I can't this time b/c I  
need the site to work even when javascript is turned off.


On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:

> valid_date('5/39/1980', -format='%-D');
>
> => false
>
> For UI, try the lovely jQuery datepicker with validate.  It is  
> skinnable with jQueryUI skins.
> http://keith-wood.name/datepick.html
> http://plugins.jquery.com/project/validate
>
> Working example (also includes time picker):
> http://www.d2sra.org/forms/sendoff/
>
> --steve
>
>
> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>
>> Has anyone already created a workaround for this problem in Lasso  
>> 8.5.
>>
>>
>> If you do this:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>.
>>
>>
>> You get this:
>> DATE TEST 1980-06-08 00:00:00
>>
>>
>>
>> This is a problem when trying to build a date value based on user  
>> input of 3 parameters (day, month and year) and check that its a  
>> valid date.
>>
>> valid_date says that the date is VALID even when its not.
>>
>>
>>
>>
>>
>> This:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>
>>
>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>
>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/',  
>> $dobYear))]</p>
>>
>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',  
>> $dobDay, '/', $dobYear)))]</p>
>>
>>
>>
>> Outputs this:
>>
>> DATE TEST 1980-06-08 00:00:00
>>
>> 1980-06-08 00:00:00
>>
>> Valid date true
>>
>>
>>
>>
>> Has someone already built a custom tag/workaround for this?  Thanks  
>> in advance.
>>
>>
>>
>>
>>
>>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]
>> >
>> To switch to the INDEX mode, E-mail to <[hidden email]
>> >
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                  <http://www.StevePiercy.com/>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]
> >
> To switch to the INDEX mode, E-mail to <[hidden email]
> >
> Send administrative queries to  <[hidden email]>
>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Johan Solve
In reply to this post by Tami Williams
Just compare the date as entered with Lasso's interpretation of it.

On Sun, Oct 31, 2010 at 5:07 AM, Tami Williams <[hidden email]> wrote:

> Has anyone already created a workaround for this problem in Lasso 8.5.
>
>
> If you do this:
>
> <p>DATE TEST [date('5/39/1980')]</p>.
>
>
> You get this:
> DATE TEST 1980-06-08 00:00:00
>
>
>
> This is a problem when trying to build a date value based on user input of 3
> parameters (day, month and year) and check that its a valid date.
>
> valid_date says that the date is VALID even when its not.
>
>
>
>
>
> This:
>
> <p>DATE TEST [date('5/39/1980')]</p>
>
> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>
> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear))]</p>
>
> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/', $dobDay,
> '/', $dobYear)))]</p>
>
>
>
> Outputs this:
>
> DATE TEST 1980-06-08 00:00:00
>
> 1980-06-08 00:00:00
>
> Valid date true
>
>
>
>
> Has someone already built a custom tag/workaround for this?  Thanks in
> advance.
>
>
>
>
>
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm   Malmö
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Israel Thompson
In reply to this post by stevepiercy
Nice!

On Oct 30, 2010, at 11:20 PM, Steve Piercy - Web Site Builder <[hidden email]> wrote:

> valid_date('5/39/1980', -format='%-D');
>
> => false
>
> For UI, try the lovely jQuery datepicker with validate.  It is skinnable with jQueryUI skins.
> http://keith-wood.name/datepick.html
> http://plugins.jquery.com/project/validate
>
> Working example (also includes time picker):
> http://www.d2sra.org/forms/sendoff/
>
> --steve
>
>
> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>
>> Has anyone already created a workaround for this problem in Lasso 8.5.
>>
>>
>> If you do this:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>.
>>
>>
>> You get this:
>> DATE TEST 1980-06-08 00:00:00
>>
>>
>>
>> This is a problem when trying to build a date value based on user input of 3 parameters (day, month and year) and check that its a valid date.
>>
>> valid_date says that the date is VALID even when its not.
>>
>>
>>
>>
>>
>> This:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>
>>
>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>
>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear))]</p>
>>
>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear)))]</p>
>>
>>
>>
>> Outputs this:
>>
>> DATE TEST 1980-06-08 00:00:00
>>
>> 1980-06-08 00:00:00
>>
>> Valid date true
>>
>>
>>
>>
>> Has someone already built a custom tag/workaround for this?  Thanks in advance.
>>
>>
>>
>>
>>
>>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>> To switch to the INDEX mode, E-mail to <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                  <http://www.StevePiercy.com/>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Tami Williams-3
In reply to this post by stevepiercy
Steve,

(for the archive)

you have a minus (-) before the D.  But its not needed.  This works:
valid_date('5/39/1980', -format='%D');

=> false

On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:

> valid_date('5/39/1980', -format='%-D');
>
> => false
>
> For UI, try the lovely jQuery datepicker with validate.  It is  
> skinnable with jQueryUI skins.
> http://keith-wood.name/datepick.html
> http://plugins.jquery.com/project/validate
>
> Working example (also includes time picker):
> http://www.d2sra.org/forms/sendoff/
>
> --steve
>
>
> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>
>> Has anyone already created a workaround for this problem in Lasso  
>> 8.5.
>>
>>
>> If you do this:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>.
>>
>>
>> You get this:
>> DATE TEST 1980-06-08 00:00:00
>>
>>
>>
>> This is a problem when trying to build a date value based on user  
>> input of 3 parameters (day, month and year) and check that its a  
>> valid date.
>>
>> valid_date says that the date is VALID even when its not.
>>
>>
>>
>>
>>
>> This:
>>
>> <p>DATE TEST [date('5/39/1980')]</p>
>>
>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>
>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/',  
>> $dobYear))]</p>
>>
>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',  
>> $dobDay, '/', $dobYear)))]</p>
>>
>>
>>
>> Outputs this:
>>
>> DATE TEST 1980-06-08 00:00:00
>>
>> 1980-06-08 00:00:00
>>
>> Valid date true
>>
>>
>>
>>
>> Has someone already built a custom tag/workaround for this?  Thanks  
>> in advance.
>>
>>
>>
>>
>>
>>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]
>> >
>> To switch to the INDEX mode, E-mail to <[hidden email]
>> >
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                  <http://www.StevePiercy.com/>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]
> >
> To switch to the INDEX mode, E-mail to <[hidden email]
> >
> Send administrative queries to  <[hidden email]>
>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

stevepiercy
Hm, so it does not matter.  Results are same with or without the
no-padding indicator ("-") in the -format string.  That looks
like a bug to me.

valid_date('05/09/1980', -format='%-D');
=> true // expected false

valid_date('5/09/1980', -format='%-D');
=> false

valid_date('05/9/1980', -format='%-D');
=> false

valid_date('5/9/1980', -format='%-D');
=> true



valid_date('05/09/1980', -format='%D');
=> true

valid_date('5/09/1980', -format='%D');
=> false

valid_date('05/9/1980', -format='%D');
=> false

valid_date('5/9/1980', -format='%D');
=> true // expected false

So if you want to deal with zero padding, you need to use a
regular expression on the input validation as well.  In most
cases this additional validation step would not be practical or
necessary, especially if you reformat the date for db storage anyway.

--steve


On 11/2/10 at 1:45 PM, [hidden email] (Tami Williams) pronounced:

>Steve,
>
>(for the archive)
>
>you have a minus (-) before the D.  But its not needed.  This works:
>valid_date('5/39/1980', -format='%D');
>
>=> false
>
>On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:
>
>>valid_date('5/39/1980', -format='%-D');
>>
>>=> false
>>
>>For UI, try the lovely jQuery datepicker with validate.  It is
>>skinnable with jQueryUI skins.
>>http://keith-wood.name/datepick.html
>>http://plugins.jquery.com/project/validate
>>
>>Working example (also includes time picker):
>>http://www.d2sra.org/forms/sendoff/
>>
>>--steve
>>
>>
>>On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>>
>>>Has anyone already created a workaround for this problem in
>>>Lasso 8.5.
>>>
>>>
>>>If you do this:
>>>
>>><p>DATE TEST [date('5/39/1980')]</p>.
>>>
>>>
>>>You get this:
>>>DATE TEST 1980-06-08 00:00:00
>>>
>>>
>>>
>>>This is a problem when trying to build a date value based on
>>>user input of 3 parameters (day, month and year) and check
>>>that its a valid date.
>>>
>>>valid_date says that the date is VALID even when its not.
>>>
>>>
>>>
>>>
>>>
>>>This:
>>>
>>><p>DATE TEST [date('5/39/1980')]</p>
>>>
>>>[var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>>
>>><p>[date(string_concatenate($dobMonth, '/', $dobDay, '/', $dobYear))]</p>
>>>
>>><p>Valid date [valid_date(date(string_concatenate($dobMonth,
>>>'/', $dobDay, '/', $dobYear)))]</p>
>>>
>>>
>>>
>>>Outputs this:
>>>
>>>DATE TEST 1980-06-08 00:00:00
>>>
>>>1980-06-08 00:00:00
>>>
>>>Valid date true
>>>
>>>
>>>
>>>
>>>Has someone already built a custom tag/workaround for this?  
>>>Thanks in advance.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>#############################################################
>>>This message is sent to you because you are subscribed to
>>>the mailing list <[hidden email]>.
>>>To unsubscribe, E-mail to: <[hidden email]>
>>>To switch to the DIGEST mode, E-mail to <[hidden email]>
>>>To switch to the INDEX mode, E-mail to <[hidden email]>
>>>Send administrative queries to  <[hidden email]>
>>>
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy               Web Site Builder               Soquel, CA
>><[hidden email]>                  <http://www.StevePiercy.com/>
>>
>>
>>#############################################################
>>This message is sent to you because you are subscribed to
>>the mailing list <[hidden email]>.
>>To unsubscribe, E-mail to: <[hidden email]>
>>To switch to the DIGEST mode, E-mail to <[hidden email]>
>>To switch to the INDEX mode, E-mail to <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>>
>
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list <[hidden email]>.
>To unsubscribe, E-mail to: <[hidden email]>
>To switch to the DIGEST mode, E-mail to <[hidden email]>
>To switch to the INDEX mode, E-mail to <[hidden email]>
>Send administrative queries to  <[hidden email]>
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Israel Thompson
Errr.. umm.. LP9, I can't get the -format= to work for any date string
I specify.. It's always "false".

Izz

On Tue, Nov 2, 2010 at 1:17 PM, Steve Piercy - Web Site Builder
<[hidden email]> wrote:

> Hm, so it does not matter.  Results are same with or without the no-padding
> indicator ("-") in the -format string.  That looks like a bug to me.
>
> valid_date('05/09/1980', -format='%-D');
> => true // expected false
>
> valid_date('5/09/1980', -format='%-D');
> => false
>
> valid_date('05/9/1980', -format='%-D');
> => false
>
> valid_date('5/9/1980', -format='%-D');
> => true
>
>
>
> valid_date('05/09/1980', -format='%D');
> => true
>
> valid_date('5/09/1980', -format='%D');
> => false
>
> valid_date('05/9/1980', -format='%D');
> => false
>
> valid_date('5/9/1980', -format='%D');
> => true // expected false
>
> So if you want to deal with zero padding, you need to use a regular
> expression on the input validation as well.  In most cases this additional
> validation step would not be practical or necessary, especially if you
> reformat the date for db storage anyway.
>
> --steve
>
>
> On 11/2/10 at 1:45 PM, [hidden email] (Tami Williams) pronounced:
>
>> Steve,
>>
>> (for the archive)
>>
>> you have a minus (-) before the D.  But its not needed.  This works:
>> valid_date('5/39/1980', -format='%D');
>>
>> => false
>>
>> On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:
>>
>>> valid_date('5/39/1980', -format='%-D');
>>>
>>> => false
>>>
>>> For UI, try the lovely jQuery datepicker with validate.  It is skinnable
>>> with jQueryUI skins.
>>> http://keith-wood.name/datepick.html
>>> http://plugins.jquery.com/project/validate
>>>
>>> Working example (also includes time picker):
>>> http://www.d2sra.org/forms/sendoff/
>>>
>>> --steve
>>>
>>>
>>> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>>>
>>>> Has anyone already created a workaround for this problem in Lasso 8.5.
>>>>
>>>>
>>>> If you do this:
>>>>
>>>> <p>DATE TEST [date('5/39/1980')]</p>.
>>>>
>>>>
>>>> You get this:
>>>> DATE TEST 1980-06-08 00:00:00
>>>>
>>>>
>>>>
>>>> This is a problem when trying to build a date value based on user input
>>>> of 3 parameters (day, month and year) and check that its a valid date.
>>>>
>>>> valid_date says that the date is VALID even when its not.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> This:
>>>>
>>>> <p>DATE TEST [date('5/39/1980')]</p>
>>>>
>>>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>>>
>>>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/',
>>>> $dobYear))]</p>
>>>>
>>>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',
>>>> $dobDay, '/', $dobYear)))]</p>
>>>>
>>>>
>>>>
>>>> Outputs this:
>>>>
>>>> DATE TEST 1980-06-08 00:00:00
>>>>
>>>> 1980-06-08 00:00:00
>>>>
>>>> Valid date true
>>>>
>>>>
>>>>
>>>>
>>>> Has someone already built a custom tag/workaround for this?  Thanks in
>>>> advance.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> #############################################################
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list <[hidden email]>.
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> To switch to the DIGEST mode, E-mail to
>>>> <[hidden email]>
>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy               Web Site Builder               Soquel, CA
>>> <[hidden email]>                  <http://www.StevePiercy.com/>
>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list <[hidden email]>.
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> To switch to the DIGEST mode, E-mail to
>>> <[hidden email]>
>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>> To switch to the INDEX mode, E-mail to <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                  <http://www.StevePiercy.com/>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Israel Thompson
I'm noticing that specifying date(string, -format='%Q') automatically
calculates incorrectly typed overages in days or months, even years,
however. Looks like it's not all in vein.

Izz

On Tue, Nov 2, 2010 at 4:21 PM, Israel Thompson
<[hidden email]> wrote:

> Errr.. umm.. LP9, I can't get the -format= to work for any date string
> I specify.. It's always "false".
>
> Izz
>
> On Tue, Nov 2, 2010 at 1:17 PM, Steve Piercy - Web Site Builder
> <[hidden email]> wrote:
>> Hm, so it does not matter.  Results are same with or without the no-padding
>> indicator ("-") in the -format string.  That looks like a bug to me.
>>
>> valid_date('05/09/1980', -format='%-D');
>> => true // expected false
>>
>> valid_date('5/09/1980', -format='%-D');
>> => false
>>
>> valid_date('05/9/1980', -format='%-D');
>> => false
>>
>> valid_date('5/9/1980', -format='%-D');
>> => true
>>
>>
>>
>> valid_date('05/09/1980', -format='%D');
>> => true
>>
>> valid_date('5/09/1980', -format='%D');
>> => false
>>
>> valid_date('05/9/1980', -format='%D');
>> => false
>>
>> valid_date('5/9/1980', -format='%D');
>> => true // expected false
>>
>> So if you want to deal with zero padding, you need to use a regular
>> expression on the input validation as well.  In most cases this additional
>> validation step would not be practical or necessary, especially if you
>> reformat the date for db storage anyway.
>>
>> --steve
>>
>>
>> On 11/2/10 at 1:45 PM, [hidden email] (Tami Williams) pronounced:
>>
>>> Steve,
>>>
>>> (for the archive)
>>>
>>> you have a minus (-) before the D.  But its not needed.  This works:
>>> valid_date('5/39/1980', -format='%D');
>>>
>>> => false
>>>
>>> On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:
>>>
>>>> valid_date('5/39/1980', -format='%-D');
>>>>
>>>> => false
>>>>
>>>> For UI, try the lovely jQuery datepicker with validate.  It is skinnable
>>>> with jQueryUI skins.
>>>> http://keith-wood.name/datepick.html
>>>> http://plugins.jquery.com/project/validate
>>>>
>>>> Working example (also includes time picker):
>>>> http://www.d2sra.org/forms/sendoff/
>>>>
>>>> --steve
>>>>
>>>>
>>>> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>>>>
>>>>> Has anyone already created a workaround for this problem in Lasso 8.5.
>>>>>
>>>>>
>>>>> If you do this:
>>>>>
>>>>> <p>DATE TEST [date('5/39/1980')]</p>.
>>>>>
>>>>>
>>>>> You get this:
>>>>> DATE TEST 1980-06-08 00:00:00
>>>>>
>>>>>
>>>>>
>>>>> This is a problem when trying to build a date value based on user input
>>>>> of 3 parameters (day, month and year) and check that its a valid date.
>>>>>
>>>>> valid_date says that the date is VALID even when its not.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> This:
>>>>>
>>>>> <p>DATE TEST [date('5/39/1980')]</p>
>>>>>
>>>>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>>>>
>>>>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/',
>>>>> $dobYear))]</p>
>>>>>
>>>>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',
>>>>> $dobDay, '/', $dobYear)))]</p>
>>>>>
>>>>>
>>>>>
>>>>> Outputs this:
>>>>>
>>>>> DATE TEST 1980-06-08 00:00:00
>>>>>
>>>>> 1980-06-08 00:00:00
>>>>>
>>>>> Valid date true
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Has someone already built a custom tag/workaround for this?  Thanks in
>>>>> advance.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> #############################################################
>>>>> This message is sent to you because you are subscribed to
>>>>> the mailing list <[hidden email]>.
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> To switch to the DIGEST mode, E-mail to
>>>>> <[hidden email]>
>>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>>
>>>>
>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>> Steve Piercy               Web Site Builder               Soquel, CA
>>>> <[hidden email]>                  <http://www.StevePiercy.com/>
>>>>
>>>>
>>>> #############################################################
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list <[hidden email]>.
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> To switch to the DIGEST mode, E-mail to
>>>> <[hidden email]>
>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list <[hidden email]>.
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>> Steve Piercy               Web Site Builder               Soquel, CA
>> <[hidden email]>                  <http://www.StevePiercy.com/>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>  the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>> To switch to the INDEX mode, E-mail to <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

list
Lasso 9, as you've noticed, does convert any string input to a valid date, if it can. As does Lasso 8.5. So
date('02/37/2002')
'<br>'
date('2009-12-37')

will in Lasso 8 -> 03/09/2002 00:00:00
01/06/2010 00:00:00

and both of those dates are valid.
Looking at the code for date_valid method reveals that it's mostly only checking that the format input date is formatted according to the format param. And since it will first convert the input to a date type it won't catch as errors inputs like 02/37/2002.

Here's the present code for valid_date:
        define valid_date(date, -format::string='') => {

                // Empty input
                #date == null ? return(false);
                string(#date)->trim & == '' ? return(false);

                // Parse date
                local(parse) = (#format != '' ? date(#date, -format=#format) | date(#date));
               
                // Invalid dates
                (#parse->type == 'null') ? return(false);
                (string(#parse)->size == 0) ? return(false);
// (#parse >> '0000') ? return(false);
               
                // Strict check of format against original date (allowing for leading zeroes or spaces)
                if(#format != '');
                        string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%')->replaceall(#format)) ? return(true);
                        string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%_')->replaceall(#format)) ? return(true);
                        string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%-')->replaceall(#format)) ? return(true);
                        return(false);
                /if;
               
                return(true);
        }

Since we want a more strict validation let's add some functionality. Put this in a file in startup and add the param -strict to your validation call.

define date->month( -long::Boolean=false, -short::Boolean=false, -days::Boolean=false ) => {
// this is to deal with a bug in the present date type that doesn't return correct values for date -> month(-days)

                #long ? return .format( '%B' )
                #short ? return .format( '%b' )
                if(#days)
                        local(tempdate = date(.format('%Q')))
                        #tempdate -> day = 1
                        #tempdate -> add(-month = 1)
                        #tempdate -> subtract(-day = 1)
                        return #tempdate -> day
                /if

                return ..get(ucal_month)+1
        }


define valid_date(date, -format::string = '', -strict::boolean) => {
// this is our alternative validate_date method that checks that the input date actually exists in real life.
// in this implementation input dates have to be of either US or ISO date formats

        if(valid_date(#date, -format = #format))

                // find out input format, we can't convert input to a date type since that will change the input values if needed
                select(true)
                        case(#format == '%D') // US date format
                                local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
                                (#parse -> size != 3 ? return false)
                                local(day = parse -> second)
                                local(month = parse -> first)
                                local(year = parse -> last)
                        case(#format == '%Q') // ISO date format
                                local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
                                (#parse -> size != 3 ? return false)
                                local(day = parse -> last)
                                local(month = parse -> second)
                                local(year = parse -> first)
                        case // assume ISO format since that is standard in Lasso 9
                                local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
                                (#parse -> size != 3 ? return false)
                                local(day = parse -> last)
                                local(month = parse -> second)
                                local(year = parse -> first)
                /select
                (#year < date -> min(-year) || #year > date -> max(-year) ? return false)
                (#month < 1 || #month > 12 ? return false)
                (#day < 1 || date(#year + '-' + #month + '-01') -> month(-days) < #day ? return false)
                return true
        else
                return false
        /if;


}

// testing
valid_date('2010-02-37', -strict)
'<br>'
valid_date('2010-02-28', -strict)

Lasso 9 ->
false
true

HDB
Jolle


3 nov 2010 kl. 07.44 skrev Israel Thompson:

> I'm noticing that specifying date(string, -format='%Q') automatically
> calculates incorrectly typed overages in days or months, even years,
> however. Looks like it's not all in vein.
>
> Izz
>
> On Tue, Nov 2, 2010 at 4:21 PM, Israel Thompson
> <[hidden email]> wrote:
>> Errr.. umm.. LP9, I can't get the -format= to work for any date string
>> I specify.. It's always "false".
>>
>> Izz
>>
>> On Tue, Nov 2, 2010 at 1:17 PM, Steve Piercy - Web Site Builder
>> <[hidden email]> wrote:
>>> Hm, so it does not matter.  Results are same with or without the no-padding
>>> indicator ("-") in the -format string.  That looks like a bug to me.
>>>
>>> valid_date('05/09/1980', -format='%-D');
>>> => true // expected false
>>>
>>> valid_date('5/09/1980', -format='%-D');
>>> => false
>>>
>>> valid_date('05/9/1980', -format='%-D');
>>> => false
>>>
>>> valid_date('5/9/1980', -format='%-D');
>>> => true
>>>
>>>
>>>
>>> valid_date('05/09/1980', -format='%D');
>>> => true
>>>
>>> valid_date('5/09/1980', -format='%D');
>>> => false
>>>
>>> valid_date('05/9/1980', -format='%D');
>>> => false
>>>
>>> valid_date('5/9/1980', -format='%D');
>>> => true // expected false
>>>
>>> So if you want to deal with zero padding, you need to use a regular
>>> expression on the input validation as well.  In most cases this additional
>>> validation step would not be practical or necessary, especially if you
>>> reformat the date for db storage anyway.
>>>
>>> --steve
>>>
>>>
>>> On 11/2/10 at 1:45 PM, [hidden email] (Tami Williams) pronounced:
>>>
>>>> Steve,
>>>>
>>>> (for the archive)
>>>>
>>>> you have a minus (-) before the D.  But its not needed.  This works:
>>>> valid_date('5/39/1980', -format='%D');
>>>>
>>>> => false
>>>>
>>>> On Oct 31, 2010, at 12:20 AM, Steve Piercy - Web Site Builder wrote:
>>>>
>>>>> valid_date('5/39/1980', -format='%-D');
>>>>>
>>>>> => false
>>>>>
>>>>> For UI, try the lovely jQuery datepicker with validate.  It is skinnable
>>>>> with jQueryUI skins.
>>>>> http://keith-wood.name/datepick.html
>>>>> http://plugins.jquery.com/project/validate
>>>>>
>>>>> Working example (also includes time picker):
>>>>> http://www.d2sra.org/forms/sendoff/
>>>>>
>>>>> --steve
>>>>>
>>>>>
>>>>> On 10/31/10 at 12:07 AM, [hidden email] (Tami Williams) pronounced:
>>>>>
>>>>>> Has anyone already created a workaround for this problem in Lasso 8.5.
>>>>>>
>>>>>>
>>>>>> If you do this:
>>>>>>
>>>>>> <p>DATE TEST [date('5/39/1980')]</p>.
>>>>>>
>>>>>>
>>>>>> You get this:
>>>>>> DATE TEST 1980-06-08 00:00:00
>>>>>>
>>>>>>
>>>>>>
>>>>>> This is a problem when trying to build a date value based on user input
>>>>>> of 3 parameters (day, month and year) and check that its a valid date.
>>>>>>
>>>>>> valid_date says that the date is VALID even when its not.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> This:
>>>>>>
>>>>>> <p>DATE TEST [date('5/39/1980')]</p>
>>>>>>
>>>>>> [var:'dobMonth' = '05', 'dobDay' = '39', 'dobYear' = '1980']
>>>>>>
>>>>>> <p>[date(string_concatenate($dobMonth, '/', $dobDay, '/',
>>>>>> $dobYear))]</p>
>>>>>>
>>>>>> <p>Valid date [valid_date(date(string_concatenate($dobMonth, '/',
>>>>>> $dobDay, '/', $dobYear)))]</p>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Outputs this:
>>>>>>
>>>>>> DATE TEST 1980-06-08 00:00:00
>>>>>>
>>>>>> 1980-06-08 00:00:00
>>>>>>
>>>>>> Valid date true
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Has someone already built a custom tag/workaround for this?  Thanks in
>>>>>> advance.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> #############################################################
>>>>>> This message is sent to you because you are subscribed to
>>>>>> the mailing list <[hidden email]>.
>>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>>> To switch to the DIGEST mode, E-mail to
>>>>>> <[hidden email]>
>>>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>>>> Send administrative queries to  <[hidden email]>
>>>>>>
>>>>>
>>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>>> Steve Piercy               Web Site Builder               Soquel, CA
>>>>> <[hidden email]>                  <http://www.StevePiercy.com/>
>>>>>
>>>>>
>>>>> #############################################################
>>>>> This message is sent to you because you are subscribed to
>>>>> the mailing list <[hidden email]>.
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> To switch to the DIGEST mode, E-mail to
>>>>> <[hidden email]>
>>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>>
>>>>
>>>>
>>>> #############################################################
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list <[hidden email]>.
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy               Web Site Builder               Soquel, CA
>>> <[hidden email]>                  <http://www.StevePiercy.com/>
>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>>  the mailing list <[hidden email]>.
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>>> To switch to the INDEX mode, E-mail to <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>  the mailing list <[hidden email]>.
>> To unsubscribe, E-mail to: <[hidden email]>
>> To switch to the DIGEST mode, E-mail to <[hidden email]>
>> To switch to the INDEX mode, E-mail to <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>
>



#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

list
I found that my suggested add-on to valid_date did not work as it should. So I made a replacement method instead. And some more extensive testing.
Anyone interested can find it on Tagswap:
http://tagswap.net/valid_date/

From the description:
"Replacement of Lasso 9 valid_date that adds an optional param -strict. If set to true it will fail on dates that doesn't exist in the real world. Like 2010-02-31.
When used with strict assumes that date inputs are either in ISO or US date format.

To use, place the file in the LassoStartup folder and restart Lasso 9."

HDB
Jolle

3 nov 2010 kl. 09.28 skrev <[hidden email]>:

> Lasso 9, as you've noticed, does convert any string input to a valid date, if it can. As does Lasso 8.5. So
> date('02/37/2002')
> '<br>'
> date('2009-12-37')
>
> will in Lasso 8 -> 03/09/2002 00:00:00
> 01/06/2010 00:00:00
>
> and both of those dates are valid.
> Looking at the code for date_valid method reveals that it's mostly only checking that the format input date is formatted according to the format param. And since it will first convert the input to a date type it won't catch as errors inputs like 02/37/2002.
>
> Here's the present code for valid_date:
>       define valid_date(date, -format::string='') => {
>
>               // Empty input
>               #date == null ? return(false);
>               string(#date)->trim & == '' ? return(false);
>
>               // Parse date
>               local(parse) = (#format != '' ? date(#date, -format=#format) | date(#date));
>
>               // Invalid dates
>               (#parse->type == 'null') ? return(false);
>               (string(#parse)->size == 0) ? return(false);
> //              (#parse >> '0000') ? return(false);
>
>               // Strict check of format against original date (allowing for leading zeroes or spaces)
>               if(#format != '');
>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%')->replaceall(#format)) ? return(true);
>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%_')->replaceall(#format)) ? return(true);
>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%-')->replaceall(#format)) ? return(true);
>                       return(false);
>               /if;
>
>               return(true);
>       }
>
> Since we want a more strict validation let's add some functionality. Put this in a file in startup and add the param -strict to your validation call.
>
> define date->month( -long::Boolean=false, -short::Boolean=false, -days::Boolean=false ) => {
> // this is to deal with a bug in the present date type that doesn't return correct values for date -> month(-days)
>
>               #long ? return .format( '%B' )
>               #short ? return .format( '%b' )
>               if(#days)
>                       local(tempdate = date(.format('%Q')))
>                       #tempdate -> day = 1
>                       #tempdate -> add(-month = 1)
>                       #tempdate -> subtract(-day = 1)
>                       return #tempdate -> day
>               /if
>
>               return ..get(ucal_month)+1
>       }
>
>
> define valid_date(date, -format::string = '', -strict::boolean) => {
> // this is our alternative validate_date method that checks that the input date actually exists in real life.
> // in this implementation input dates have to be of either US or ISO date formats
>
>       if(valid_date(#date, -format = #format))
>
>               // find out input format, we can't convert input to a date type since that will change the input values if needed
>               select(true)
>                       case(#format == '%D') // US date format
>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>                               (#parse -> size != 3 ? return false)
>                               local(day = parse -> second)
>                               local(month = parse -> first)
>                               local(year = parse -> last)
>                       case(#format == '%Q') // ISO date format
>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>                               (#parse -> size != 3 ? return false)
>                               local(day = parse -> last)
>                               local(month = parse -> second)
>                               local(year = parse -> first)
>                       case // assume ISO format since that is standard in Lasso 9
>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>                               (#parse -> size != 3 ? return false)
>                               local(day = parse -> last)
>                               local(month = parse -> second)
>                               local(year = parse -> first)
>               /select
>               (#year < date -> min(-year) || #year > date -> max(-year) ? return false)
>               (#month < 1 || #month > 12 ? return false)
>               (#day < 1 || date(#year + '-' + #month + '-01') -> month(-days) < #day ? return false)
>               return true
>       else
>               return false
>       /if;
>
>
> }
>
> // testing
> valid_date('2010-02-37', -strict)
> '<br>'
> valid_date('2010-02-28', -strict)
>
> Lasso 9 ->
> false
> true
>
> HDB
> Jolle
>
>
> 3 nov 2010 kl. 07.44 skrev Israel Thompson:
>
>> I'm noticing that specifying date(string, -format='%Q') automatically
>> calculates incorrectly typed overages in days or months, even years,
>> however. Looks like it's not all in vein.
>>
>> Izz
>>
>> On Tue, Nov 2, 2010 at 4:21 PM, Israel Thompson
>> <[hidden email]> wrote:
>>> Errr.. umm.. LP9, I can't get the -format= to work for any date string
>>> I specify.. It's always "false".
>>>
>>> Izz



#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Israel Thompson
Jolle, you're quickly rising to the ranks alongside The Joker, Mister
Mxyzptlk and Lex Luthor (my beloved heroes) :)

No, really... You're awesome! Thanks for this!

Izz

On Wed, Nov 3, 2010 at 1:56 AM,  <[hidden email]> wrote:

> I found that my suggested add-on to valid_date did not work as it should. So I made a replacement method instead. And some more extensive testing.
> Anyone interested can find it on Tagswap:
> http://tagswap.net/valid_date/
>
> From the description:
> "Replacement of Lasso 9 valid_date that adds an optional param -strict. If set to true it will fail on dates that doesn't exist in the real world. Like 2010-02-31.
> When used with strict assumes that date inputs are either in ISO or US date format.
>
> To use, place the file in the LassoStartup folder and restart Lasso 9."
>
> HDB
> Jolle
>
> 3 nov 2010 kl. 09.28 skrev <[hidden email]>:
>
>> Lasso 9, as you've noticed, does convert any string input to a valid date, if it can. As does Lasso 8.5. So
>> date('02/37/2002')
>> '<br>'
>> date('2009-12-37')
>>
>> will in Lasso 8 -> 03/09/2002 00:00:00
>> 01/06/2010 00:00:00
>>
>> and both of those dates are valid.
>> Looking at the code for date_valid method reveals that it's mostly only checking that the format input date is formatted according to the format param. And since it will first convert the input to a date type it won't catch as errors inputs like 02/37/2002.
>>
>> Here's the present code for valid_date:
>>       define valid_date(date, -format::string='') => {
>>
>>               // Empty input
>>               #date == null ? return(false);
>>               string(#date)->trim & == '' ? return(false);
>>
>>               // Parse date
>>               local(parse) = (#format != '' ? date(#date, -format=#format) | date(#date));
>>
>>               // Invalid dates
>>               (#parse->type == 'null') ? return(false);
>>               (string(#parse)->size == 0) ? return(false);
>> //              (#parse >> '0000') ? return(false);
>>
>>               // Strict check of format against original date (allowing for leading zeroes or spaces)
>>               if(#format != '');
>>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%')->replaceall(#format)) ? return(true);
>>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%_')->replaceall(#format)) ? return(true);
>>                       string(#date) == #parse->format(regexp(-find='%-?_?', -replace='%-')->replaceall(#format)) ? return(true);
>>                       return(false);
>>               /if;
>>
>>               return(true);
>>       }
>>
>> Since we want a more strict validation let's add some functionality. Put this in a file in startup and add the param -strict to your validation call.
>>
>> define date->month( -long::Boolean=false, -short::Boolean=false, -days::Boolean=false ) => {
>> // this is to deal with a bug in the present date type that doesn't return correct values for date -> month(-days)
>>
>>               #long ? return .format( '%B' )
>>               #short ? return .format( '%b' )
>>               if(#days)
>>                       local(tempdate = date(.format('%Q')))
>>                       #tempdate -> day = 1
>>                       #tempdate -> add(-month = 1)
>>                       #tempdate -> subtract(-day = 1)
>>                       return #tempdate -> day
>>               /if
>>
>>               return ..get(ucal_month)+1
>>       }
>>
>>
>> define valid_date(date, -format::string = '', -strict::boolean) => {
>> // this is our alternative validate_date method that checks that the input date actually exists in real life.
>> // in this implementation input dates have to be of either US or ISO date formats
>>
>>       if(valid_date(#date, -format = #format))
>>
>>               // find out input format, we can't convert input to a date type since that will change the input values if needed
>>               select(true)
>>                       case(#format == '%D') // US date format
>>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>>                               (#parse -> size != 3 ? return false)
>>                               local(day = parse -> second)
>>                               local(month = parse -> first)
>>                               local(year = parse -> last)
>>                       case(#format == '%Q') // ISO date format
>>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>>                               (#parse -> size != 3 ? return false)
>>                               local(day = parse -> last)
>>                               local(month = parse -> second)
>>                               local(year = parse -> first)
>>                       case // assume ISO format since that is standard in Lasso 9
>>                               local(parse = (string(#date) -> split(' ')) -> first) // get rid of the time part
>>                               (#parse -> size != 3 ? return false)
>>                               local(day = parse -> last)
>>                               local(month = parse -> second)
>>                               local(year = parse -> first)
>>               /select
>>               (#year < date -> min(-year) || #year > date -> max(-year) ? return false)
>>               (#month < 1 || #month > 12 ? return false)
>>               (#day < 1 || date(#year + '-' + #month + '-01') -> month(-days) < #day ? return false)
>>               return true
>>       else
>>               return false
>>       /if;
>>
>>
>> }
>>
>> // testing
>> valid_date('2010-02-37', -strict)
>> '<br>'
>> valid_date('2010-02-28', -strict)
>>
>> Lasso 9 ->
>> false
>> true
>>
>> HDB
>> Jolle
>>
>>
>> 3 nov 2010 kl. 07.44 skrev Israel Thompson:
>>
>>> I'm noticing that specifying date(string, -format='%Q') automatically
>>> calculates incorrectly typed overages in days or months, even years,
>>> however. Looks like it's not all in vein.
>>>
>>> Izz
>>>
>>> On Tue, Nov 2, 2010 at 4:21 PM, Israel Thompson
>>> <[hidden email]> wrote:
>>>> Errr.. umm.. LP9, I can't get the -format= to work for any date string
>>>> I specify.. It's always "false".
>>>>
>>>> Izz
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list <[hidden email]>.
> To unsubscribe, E-mail to: <[hidden email]>
> To switch to the DIGEST mode, E-mail to <[hidden email]>
> To switch to the INDEX mode, E-mail to <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: lasso 8.5 date bug - any workarounds

Bil Corry-3
In reply to this post by Tami Williams
Tami Williams wrote on 10/30/2010 9:07 PM:

> Has anyone already created a workaround for this problem in Lasso 8.5.
>
>
> If you do this:
>
> <p>DATE TEST [date('5/39/1980')]</p>.
>
>
> You get this:
> DATE TEST 1980-06-08 00:00:00

I use [lp_date_stringtodate] to convert arbitrary datestrings into the Lasso date type.

=========================================================
[lp_date_stringtodate('5/39/1980',-error=false)]
[lp_date_stringtodate('6/31/1980',-error=false)]
[lp_date_stringtodate('2/29/2010',-error=false)]
[lp_date_stringtodate('1/1/1980',-error=false)]

LP8  =>  false
         false
         false
         01/01/1980 00:00:00
=========================================================


I still need to update it for Lasso 9.  But the LP8.5 tag is here:

        http://tagswap.net/lp_date_stringtodate

Note that it has a lot of dependencies, better to just grab the entire library:

        http://tagswap.net/lp__library

- Bil

#############################################################
This message is sent to you because you are subscribed to
  the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
To switch to the DIGEST mode, E-mail to <[hidden email]>
To switch to the INDEX mode, E-mail to <[hidden email]>
Send administrative queries to  <[hidden email]>