|
of_weeknumber
|
|
Full name
|
pfc_n_cst_datetime.of_weeknumber
|
Access
|
public
|
Extend of
|
long
|
Return value
|
long
|
Prototype
|
public function long of_weeknumber(date)
|
Name
|
Datatype
|
ld_first_ofyear
|
date
|
li_leftover_days
|
integer
|
li_weeknumber
|
integer
|
ll_null
|
long
|
public function long of_weeknumber (date ad_source);////////////////////////////////////////////////////////////////////////////////
//
// Function: of_WeekNumber
//
// Access: public
//
// Arguments:
// ad_source Date to be determined.
//
// Returns: long
// If any argument's value is NULL, function returns NULL.
// If any argument's value is Invalid, function returns -1.
//
// Description: Obtains the week number that corresponds to the date from
// the begining of the year.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
date ld_first_ofyear
integer li_weeknumber
integer li_leftover_days
//Check parameters
If IsNull(ad_source) Then
long ll_null
SetNull(ll_null)
Return ll_null
End If
//Check for invalid date
If Not of_IsValid(ad_source) Then
Return -1
End If
//Set to the first of the same year.
ld_first_ofyear = Date(Year(ad_source), 01, 01)
//Get the number of weeks passed from the begining of the year.
li_weeknumber = of_WeeksAfter (ld_first_ofyear, ad_source)
//Get the leftover days.
li_leftover_days = Mod(DaysAfter (ld_first_ofyear, ad_source), 7)
//If needed, increment the weeks count by one.
If (of_DayOfWeek(ld_first_ofyear) + li_leftover_days) >= 8 then
li_weeknumber ++
End If
Return li_weeknumber
end function