|
of_lastdayofmonth
|
|
Full name
|
pfc_n_cst_datetime.of_lastdayofmonth
|
Access
|
public
|
Extend of
|
date
|
Return value
|
date
|
Prototype
|
public function date of_lastdayofmonth(date)
|
Name
|
Datatype
|
ldt_null
|
date
|
li_day
|
integer
|
li_month
|
integer
|
li_year
|
integer
|
public function date of_lastdayofmonth (date ad_source);//////////////////////////////////////////////////////////////////////////////
//
// 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
// 7.0 Removed a loop which relied on an invalid date.
//
//////////////////////////////////////////////////////////////////////////////
//
// 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)
If li_month = 2 and of_isleapyear(date(li_year, 01, 01)) Then
li_day = 29
Else
li_day = ii_daysinmonth[li_month]
end If
Return (Date(li_year, li_month, li_day))
end function