PowerBASIC Forums
  PowerBASIC for Windows
  Week of Day ? (Page 2)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone!
This topic is 3 pages long:   1  2  3 
next newest topic | next oldest topic
Author Topic:   Week of Day ?
Egbert Zijlema
Member
posted January 03, 2006 07:31 PM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Matthias,

Wilkommen!

I mean, you're welcome to use my code, but as soon as you're going to write code for the international market, you may feel the need for a routine that covers the 3 possibilities as mentioned here before.
Anyhow, tomorrow (Mittwoch/Wednesday) it will be downloadable from my website.

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

Egbert Zijlema
Member
posted January 04, 2006 08:55 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Done, folks!

My Gregorian functions now include a week number routine that takes Windows settings in account.
You may download it here: http://www.egbertzijlema.nl/files/gregorian.zip .

Finally, I have a question for programmers in Belgium, France, Spain and the UK:
is it correct that in your country the week containing January 1 is considered to be week 1?
This is what Windows returns, but it is not in accordance with ISO-rules, which should be mandatory in the
European Union.

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

Michael Mattias
Member
posted January 04, 2006 08:56 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
>It's in the registry. See: HKEY_CURRENT_USER\Control Panel\International

Mine just has a key=Locale, value '00000409'

I guess the installed locale has these settings 'built in' so you just have to deal with it.

Oh well, I guess that's why programming languages exist.. so some ambitious programmer could create a function like...


FUNCTION GetWeekNumber (date, weekMethod, firstdayofweek, OPTIONAL LocalId AS LONG) AS LONG
'
' get the info for current, default or specified locale, massage until done
'


.. or something like that.

Good to know, though.

MCM


IP: Logged

Egbert Zijlema
Member
posted January 04, 2006 09:09 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Michael,

I wonder, do you have W98? Maybe in that case you'll find those settings in WIN.INI.

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

Michael Mattias
Member
posted January 04, 2006 09:30 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
Well, yes I am on Win/98

Maybe it's one of these from Win.ini...


[intl]
slanguage=enu
iCountry=1
ICurrDigits=2
iCurrency=0
iDate=0
iDigits=2
iLZero=1
iMeasure=1
iNegCurr=0
iTime=0
iTLZero=0
s1159=AM
s2359=PM
sCountry=United States
sCurrency=$
sDate=/
sDecimal=.
sList=,
sLongDate=dddd, MMMM dd, yyyy
sShortDate=M/d/yy
sThousand=,
sTime=:

Not really important, but I think I'll check our your stuff anyway. from description, you just might be that 'ambitious programmer' mentioned earlier...

IP: Logged

Michael Mattias
Member
posted January 04, 2006 09:37 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
Great start..

' *************************************************************************
' * Function WeekNumber in accordance with Windows settings *
' * *
' * %LOCALE_IFIRSTWEEKOFYEAR returns one of the following: *
' * 0 = week containing Jan. 1 is first week *
' * 1 = first full week is first week *
' * 2 = week containing at least 4 days is first week [ISO 8601] *
' * *
' * %LOCALE_IFIRSTDAYOFWEEK returns one of the 7 weekdays: *
' * 0 = Monday [ISO 8601] *
' * thru *
' * 6 = Sunday *
' * *
' *************************************************************************
FUNCTION WeekNumber(wYear AS WORD, wMonth AS WORD, wDay AS WORD, iLocale AS LONG) AS BYTE

Since we can't post ZIP files in source code forum, might I suggest this (shamelessly copied from the "files" section of this web site).....

"Got a file to contribute?
E-mail it to files@powerbasic.com
Thanks for sharing your code!"


[This message has been edited by Michael Mattias (edited January 04, 2006).]

IP: Logged

Egbert Zijlema
Member
posted January 04, 2006 10:06 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Michael,

I do not quite understand what you mean. I've shared several files with PB. They're available from their Download section.
This one was and is meant for my own website. What difference does it make for you to download it either from their or from my website?

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

John Schexnaydre
Member
posted January 04, 2006 10:27 AM     Click Here to See the Profile for John Schexnaydre     Edit/Delete Message   Reply w/Quote

To make the Ver 8 complier happy, I needed to change this line in GREGORIAN.INC:

IF ISFALSE(GetDateFormat iLocale, dwShortLong, lpDate, "", szDate, SIZEOF(szDate)) THEN
' error detected by Windows. Eventually use GetLastError() to find out which one.
FUNCTION = ""
EXIT FUNCTION
END IF

To:

IF ISFALSE(GetDateFormat( iLocale, dwShortLong, lpDate, "", szDate, SIZEOF(szDate))) THEN
' error detected by Windows. Eventually use GetLastError() to find out which one.
FUNCTION = ""
EXIT FUNCTION
END IF

------------------

IP: Logged

Egbert Zijlema
Member
posted January 04, 2006 10:37 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Thank you John,

Corrected! Version 7.04 obviously accepts this syntax error.

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

Michael Mattias
Member
posted January 04, 2006 10:44 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
quote:

What difference does it make for you to download it either from their or from my website?

For downloading? No difference. But finding it when you need it is another matter.

IP: Logged

Egbert Zijlema
Member
posted January 05, 2006 08:12 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Thank you very much, Michael Mattias.

I've, indeed, made the iLocale-param OPTIONAL BYVAL now (in every function where it is passed).
So, if it is omitted, the function defaults to 0, which happens to be the value of %LOCALE_USER_DEFAULT.
Furthermore I've optimized the Function GregDateFormat a little. So grab the latest version from: http://www.egbertzijlema.nl/files/gregorian.zip

I'm still waiting for an intelligent answer from a Belgian, French, Spanish or British chap.
Greetings,


------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

[This message has been edited by Egbert Zijlema (edited January 05, 2006).]

IP: Logged

Michael Mattias
Member
posted January 05, 2006 09:20 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
>I've, indeed, made the iLocale-param OPTIONAL

OPTIONAL parameters (especially since the compiler started supporting them without all the CDECL and square brackets crap) are a really, really nice feature, especially for doing 'backward compatible' upgrades.

IP: Logged

Egbert Zijlema
Member
posted May 19, 2006 02:15 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Just to inform you: new article and new code at http://www.egbertzijlema.nl/programming.html

------------------
Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl)
http://www.egbertzijlema.nl/programming.html
*** Opinions expressed here are not necessarily untrue ***

IP: Logged

Henning Wallgren
Member
posted December 21, 2006 07:50 AM     Click Here to See the Profile for Henning Wallgren     Edit/Delete Message   Reply w/Quote
Did anybody download Egbert's code (zip-file)? Just went to his website and it's down so no way to get hold of the code.

Yes, submitting the code to pb would have been a good idea.. However, I looked there and it doesn't seem like much have been uploaded there in years anyways?

If you have Egbert's latest code, will you please email it to me: HENNING at DIARY dut ST

Thx,

------------------
Henning

IP: Logged

Egbert Zijlema
Member
posted December 21, 2006 08:16 AM     Click Here to See the Profile for Egbert Zijlema     Edit/Delete Message   Reply w/Quote
Henning,

The site mentioned here is down. Webhosting is too expensive for me, being just an amateur.
Try the programming site below.

------------------
Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
http://zijlema.basicguru.eu
*** Opinions expressed here are not necessarily untrue ***

IP: Logged


This topic is 3 pages long:   1  2  3 

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c