![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Date to DayOfWeek Topic Summary: Created On: 25-May-2004 19:45 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: Hi Louie, I hope, that's what You are looking fore : int dayOfWeek (Date d) { return ((intOf (d) / DATES_INC_SECONDS_PER_DAY) + 4) % 7 } string DATES_INC_DAYS_OF_WEEK[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"} string dayOfWeek (Date d) { return DATES_INC_DAYS_OF_WEEK[((intOf (d) / DATES_INC_SECONDS_PER_DAY) + 4) % 7] } Greetings Reik Schroeder Siemens AG Berlin | |
![]() |
|
Anybody got a function that will turn a date "2004-May-25", into the day of the week "Tuesday"?
- Louie |
|
![]() |
|
![]() |
|
Hi Louie,
I hope, that's what You are looking fore : int dayOfWeek (Date d) { return ((intOf (d) / DATES_INC_SECONDS_PER_DAY) + 4) % 7 } string DATES_INC_DAYS_OF_WEEK[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"} string dayOfWeek (Date d) { return DATES_INC_DAYS_OF_WEEK[((intOf (d) / DATES_INC_SECONDS_PER_DAY) + 4) % 7] } Greetings Reik Schroeder Siemens AG Berlin ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany |
|
![]() |
|
![]() |
|
sorry I forgot the following declaration :
int DATES_INC_SECONDS_PER_DAY = 60*60*24 Reik ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany |
|
![]() |
|
![]() |
|
Reik,
There is a 'quirk' in the use of the intOf(Date d) function that caught me out recently: If (Date d) corresponds to a period when Daylight Saving Time (or in my case British Summer Time) is in effect, the value returned by intOf is not an integer number of 24-hour periods, it is one hour less. This may affect the solution you suggest (not sure). |
|
![]() |
|
![]() |
|
Louie,
I found an implementation of Zeller's congruence at this site that seems to do the trick. ------------------------- Michael Sutherland michael@galactic-solutions.com http://galactic-solutions.com |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Date to DayOfWeek
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.