driessen wrote:Uwe,
...
It is normal to my opinion. 52 weeks are 364 days so there are 1 or 2 additional days.
...
Happy 2009 to you all.
Regards,
ukoenig wrote:Hello Stefan,
29.12.2008 = 1. Week in January 2009
What is correct now ?
Week 53 in 2008 or Week 1 in 2009 ?
*
ÕìÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³ FUNCTION WOYEAR()
ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³
³ Short:
³ ------
³ WOYEAR() Calculates week of the year (# of 7 day periods)
³
³ Returns:
³ --------
³ <nWeek> => week of the year of date
³
³ Syntax:
³ -------
³ WOYEAR(dDate)
³
³ Description:
³ ------------
³ Calculates number of 7 day periods passed for the
³ year from <dDate>
³
³ Examples:
³ ---------
³ dDate := ctod("10/15/90")
³
³ nWoYear := WOYEAR(dDate)
³
³ // (returns 40)
³
³ Source:
³ -------
³ S_WOYEAR.PRG
³
ÔíÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
*/
FUNCTION woyear(dDate)
local nDayOfYear := DOYEAR(dDate)
RETURN INT(nDayOfYear/7)+IIF(nDayOfYear%7>0,1,0)
/*
ÕìÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³ FUNCTION DOYEAR()
ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³
³ Short:
³ ------
³ DOYEAR() Calculates day of the year from date
³
³ Returns:
³ --------
³ <nDayOfYear> => day of the year of date
³
³ Syntax:
³ -------
³ DOYEAR(dTarget)
³
³ Description:
³ ------------
³ Calculates day of the year from <dTarget>
³
³ Examples:
³ ---------
³ dDate := ctod("10/15/90")
³ nDoYear := DOYEAR(dDate) //(returns 288)
³
³ Source:
³ -------
³ S_DOYEAR.PRG
³
ÔíÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
*/
FUNCTION doyear(dInDate)
local nOldDate, nReturn
nOldDate := SET_DATE(1)
nReturn := dInDate- CTOD("01/01/"+RIGHT(DTOC(dInDate),2)) +1
SET_DATE(nOldDate)
RETURN nReturn
#define D_AMERICAN "mm/dd/yy"
#define D_ANSI "yy.mm.dd"
#define D_BRITISH "dd/mm/yy"
#define D_FRENCH "dd/mm/yy"
#define D_GERMAN "dd.mm.yy"
#define D_ITALIAN "dd-mm-yy"
#define D_JAPANESE "yy/mm/dd"
#define D_USA "mm-dd-yy"
/*
ÕìÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³ FUNCTION SET_DATE()
ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³
³ Short:
³ ------
³ SET_DATE() Sets and restores date format
³
³ Returns:
³ --------
³ <nFormat> => previous SET DATE format 1-5
³
³ Syntax:
³ -------
³ SET_DATE([nFormatNew])
³
³ Description:
³ ------------
³ Return current SET DATE setting <nFormat> and
³ optionally set to new format [nFormatNew]
³
³ [nFormatNew] = 1 American
³ 2 British/French
³ 3 German
³ 4 ANSI
³ 5 Italian
³
³ Examples:
³ ---------
³ nOldformat := SET_DATE(5)
³
³ ** SET TO ITALIAN
³
³ * code
³
³ * more code
³
³ SET_DATE(nOldformat) // restore to prior setting
³
³ Source:
³ -------
³ S_SETDAT.PRG
³
ÔíÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
*/
FUNCTION SET_DATE(nNewFormat)
local nOldFormat,cOldFormat
local lOldCent := SETCENT(.f.)
nOldFormat := 0
cOldFormat := lower(SET(_SET_DATEFORMAT))
do case
case cOldFormat == D_AMERICAN
nOldFormat := 1
case cOldFormat == D_BRITISH
nOldFormat := 2
case cOldFormat == D_FRENCH
nOldFormat := 2
case cOldFormat == D_GERMAN
nOldFormat := 3
case cOldFormat == D_ANSI
nOldFormat := 4
case cOldFormat == D_ITALIAN // last, but not least
nOldFormat := 5
endcase
if nNewFormat#nil
DO CASE
CASE nNewFormat = 1
SET DATE AMERICAN
CASE nNewFormat = 2
SET DATE BRITISH
CASE nNewFormat = 3
SET DATE GERMAN
CASE nNewFormat = 4
SET DATE ANSI
CASE nNewFormat = 5
SET DATE ITALIAN
ENDCASE
endif
SETCENT(lOldCent)
return nOldFormat
/*
ÕìÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³ FUNCTION SETCENT()
ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³
³ Short:
³ ------
³ SETCENT() Determines if century is on/off
³
³ Returns:
³ --------
³ <lCentury> => Century is on/off
³
³ Syntax:
³ -------
³ SETCENT([lCentury])
³
³ Description:
³ ------------
³ Returns current SET CENTURY setting and optionally
³ sets century on/off
³
³ [lCentury] True = ON False = OFF
³
³ Examples:
³ ---------
³ lOldcentury := SETCENT(.f.) // SET CENTURY OFF
³
³ // code
³
³ SETCENT(lOldcentury)
³
³ Source:
³ -------
³ S_SETCEN.PRG
³
ÔíÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
*/
FUNCTION SETCENT(lCentury)
local lOld
lOld = (LEN(DTOC(DATE()))==10)
if lCentury#nil
SET CENTURY (lCentury)
endif
return lOld
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 54 guests