Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Date to DayOfWeek
Topic Summary:
Created On: 25-May-2004 19:45
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Reik Schroeder, on Wednesday, May 26, 2004 11:07 PM

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
 25-May-2004 19:45
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Anybody got a function that will turn a date "2004-May-25", into the day of the week "Tuesday"?

- Louie
Report this to a Moderator Report this to a Moderator
 26-May-2004 10:44
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Answer 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

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 26-May-2004 10:45
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

sorry I forgot the following declaration :


int DATES_INC_SECONDS_PER_DAY = 60*60*24


Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 26-May-2004 11:31
User is offline View Users Profile Print this message


Paul Worrall

Posts: 87
Joined: 30-Sep-2003

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).
Report this to a Moderator Report this to a Moderator
 26-May-2004 13:09
User is offline View Users Profile Print this message


Michael Sutherland

Posts: 248
Joined: 13-Sep-2002

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.