|
of_gregorian
|
|
Full name
|
pfc_n_cst_datetime.of_gregorian
|
Access
|
public
|
Extend of
|
date
|
Return value
|
date
|
Prototype
|
public function date of_gregorian(long)
|
Name
|
Datatype
|
ldt_null
|
date
|
li_day
|
int
|
li_DaysInMonth
|
int[12]
|
li_month
|
int
|
li_year
|
int
|
ll_cent
|
long
|
ll_numc
|
long
|
ll_numq
|
long
|
ll_numqc
|
long
|
ll_quad
|
long
|
public function date of_gregorian (long al_julian);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Gregorian
//
// Access: public
//
// Arguments:
// al_julian Julian date
//
// Returns: date
// Converted from julian.
// If al_julian is NULL, function returns NULL.
//
// Description: Converts a julian date to gregorian date.
// Note: Julian zero day is Jan. 1, year 0000.
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
//Check parameters
If IsNull(al_julian) Then
date ldt_null
SetNull(ldt_null)
Return ldt_null
End If
long ll_numqc
long ll_numq
long ll_numc
long ll_cent = 36524
long ll_quad = 1461
int li_year, li_month, li_day
int li_DaysInMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31}
ll_numqc = al_julian / 146097 // 4 centuries
li_year = int(ll_Numqc) * 400
al_julian -= (146097 * ll_numqc)
ll_numc = 0
If al_julian > (ll_cent + 1) Then
al_julian -= (ll_cent + 1)
li_year += 100
ll_numc = al_julian / ll_cent
li_year += int(ll_numc) * 100
al_julian -= ll_numc * ll_cent
ll_numc ++
End If
If (ll_numc > 0) and (al_julian > (ll_quad - 1)) Then
al_julian -= (ll_quad - 1)
li_year += 4
End If
ll_numq = al_julian / ll_quad
li_year += int(ll_numq) * 4
al_julian -= ll_numq* ll_quad
If (of_IsLeapYear(Date(li_year, 1, 1))) Then
If al_julian >= 366 Then
al_julian -=366
li_year ++
elseif (al_julian = 59) Then
li_month = 2
li_day = 29
Return Date(li_year,li_month,li_day)
elseif (al_julian > 59) Then
al_julian --
end if
end if
Do While al_julian >= 365
al_julian -=365
li_year ++
loop
li_month = 0
Do While (li_DaysinMonth[li_month+1] <= al_julian)
al_julian -= li_DaysinMonth[li_month+1]
li_month++
Loop
li_month ++
li_day = al_julian + 1
Return Date(li_year,li_month,li_day)
end function
Name
|
Owner
|
systemfunctions.date |
systemfunctions
|
systemfunctions.int |
systemfunctions
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.setnull |
systemfunctions
|
pfc_n_cst_datetime.of_isleapyear |
pfc_n_cst_datetime
|