ISO 8601 Week Numbers

Re: ISO 8601 Week Numbers

Postby StefanHaupt » Wed Dec 31, 2008 12:42 am

my pleasure :D
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: ISO 8601 Week Numbers

Postby ukoenig » Wed Dec 31, 2008 1:21 am

Hello Stefan,

29.12.2008 = 1. Week in January 2009
Image

What is correct now ?
Week 53 in 2008 or Week 1 in 2009 ?

Regards
Uwe :roll:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: ISO 8601 Week Numbers

Postby driessen » Wed Dec 31, 2008 11:31 am

Uwe,

Normally 29th, 30th and 31st of December 2008 are in week 53,
1st, 2nd, 3rd and 4th of January 2009 are in week 1.

It is normal to my opinion. 52 weeks are 364 days so there are 1 or 2 additional days. Depending what day of week January 1st is, there are more than 2 days in week 53.

Happy 2009 to you all.

Regards,
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ISO 8601 Week Numbers

Postby Detlef Hoefner » Wed Dec 31, 2008 11:53 am

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,

Michel,

unfortunatelly ISO 8601 does not care for 'normal opinions' or 'normal thinking'. :|

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: ISO 8601 Week Numbers

Postby StefanHaupt » Wed Dec 31, 2008 3:17 pm

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 ?


Hi Uwe,

In 2008 there is no 53th week, week 1 of 2009 is correct.

There would be only a 53th week if at least 4 days of the last week are in the old year, beginning on Monday as the first day of the week. If today (31.12.08) would be a Thursday, 2008 would have 53 weeks. It´s very impotant to have in mind that the first day of a week is Monday.

Einen Guten Rutsch in´s Neue Jahr
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: ISO 8601 Week Numbers

Postby George » Wed Dec 31, 2008 7:18 pm

Hi Darrel,

Try this code and let me know if it's working fine for you.

Code: Select all  Expand view  RUN
*
ÕìÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
³ 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




Regards,


George
George
 
Posts: 726
Joined: Tue Oct 18, 2005 6:49 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests