I decided to fix the object function pfc_n_cst_datetime(OF_LastDayOFMonth())
in my corporate layer ..... Code follows if anyone wants or needs .....
////////////////////////////////////////////////////////////////////////////
//
//
//      Function:               of_LastDayOfMonth
//
//      Access:                 public
//
//      Arguments:
//      ad_source               Date to test.
//
//      Returns:                date
//                                              The last date of the month
passed.
//                                              If any argument's value is
NULL, function returns NULL.
//                                              If any argument's value is
Invalid, function returns 1900-01-01.
//
//      Description:    Given a date, will determine the last day of the
month.
//
////////////////////////////////////////////////////////////////////////////
//
//
//      Revision History
//
//      Version
//      5.0   Initial version
//      5.0.03  Fixed - function would fail under some international date
sets
// 6.5  09/02/1999 RJ Crawford Fixed - Function would return invalid date if
month
//                                      passed had any value other than 31 
//                                      (Good Job Powersoft !)
//
////////////////////////////////////////////////////////////////////////////
//
//
//      Copyright � 1996-1997 Sybase, Inc. and its subsidiaries.  All rights
reserved.
//      Any distribution of the PowerBuilder Foundation Classes (PFC)
//      source code by other than Sybase, Inc. and its subsidiaries is
prohibited.
//
////////////////////////////////////////////////////////////////////////////
//

integer li_year, li_month, li_day

//Check parameters
If IsNull(ad_source) Then
        date ldt_null
        SetNull(ldt_null)
        Return ldt_null
End If

//Check for invalid date
If Not of_IsValid(ad_source) Then
        Return ad_source
End If

li_year = Year(ad_source)
li_month = Month(ad_source)
li_day = 31

CHOOSE CASE li_Month
        CASE 4,6,9,11
                        li_day = 30
                CASE 2
                        IF of_isleapyear(ad_source) THEN
                                li_day = 29
                        ELSE
                                li_day = 28
                        END IF
END CHOOSE

//Check for a valid day (i.e., February 30th is never a valid date)

// NOTE::: Bug in loop - DATE function returns 1900-01-01 if out of range
date passed. The function of_IsValid(1900-01-01) retuns this // as a valid
date  so li_day stays as the initialized value of 31 and 09/31/99 get return
as the last day of month which is invalid ..... 

Do While Not of_IsValid(Date(li_year, li_month, li_day)) &
                and li_day > 0
        li_day --
Loop

Return (Date(li_year, li_month, li_day))

 

> -----Original Message-----
> From: Crawford, Robert 
> Sent: Thursday, September 02, 1999 10:08 AM
> To:   '[EMAIL PROTECTED]'
> Subject:      re: Known Bug in pfc_n_cst_datetime(OF_LastDayOFMonth())
> 
> PB/PFCers ... Has anyone come across the bug in object function of
> pfc_n_cst_datetime named of_lastdayofmonth(Today()) .... It returns an
> invalid date whenever the month has 30 days ....(like this one !!!) ....
> Is there a fix or should I make my own mods ???? Thanks .... RJC
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE:   help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]

Reply via email to