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: Alogrithm Approach on Presenting Dates
Topic Summary:
Created On: 30-Jul-2007 19:34
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 Tony Goodman, on Tuesday, July 31, 2007 4:55 PM

Answer:
This function takes a year as a parameter and returns true if it is a leap year, otherwise false.
 30-Jul-2007 19:34
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

I need some assistance on developing an algorithm.

On a GUI, the end-user selects a date in the format of month/day/year.

Lets say that "May 8 2007" is selected.

What I need to do is...

1) Take the selected date and go back to the first of the month.
2) Go back 11 months and capture the first and last day of the months.
3) Present the dates to the user.

For example, with "May 8 2007" still selected the end-user will receive

- May 8 2007 to May 1 2007
- April 30 2007 to April 1 2007
- March 31 2007 to March 1 2007
- February 28 2007 to February 1 2007
- January 31 2007 to January 1 2007
- December 31 2006 to December 1 2006
- November 30 2006 to November 1 2006
- October 31 2006 to October 1 2006
- September 30 2006 to September 1 2006
- August 31 2006 to August 1 2006
- July 31 2006 to July 1 2006
- June 30 2006 to June 1 2006
- May 31 2006 to May 1 2006

The concern I have doing this is I don't know how to capture leap years. The years that I only have to support are from present to 2002.

Any suggestions on how to approach this?

-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 31-Jul-2007 15:12
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Answer Answer
This function takes a year as a parameter and returns true if it is a leap year, otherwise false.

-------------------------
Tony Goodman
http://www.smartdxl.com

Edited: 31-Jul-2007 at 15:32 by Tony Goodman
Report this to a Moderator Report this to a Moderator
 31-Jul-2007 16:49
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

Tony:

Thanks for a reply. I really appreciate it.

Tony and the rest:

Attached is pseudo code I am working on to resolve my problem. I know my code aint perfect but it is a start.

-------------------------
pete.kowalski(at)motorola.com

Edited: 31-Jul-2007 at 16:52 by Pete Kowalski
Report this to a Moderator Report this to a Moderator
 1-Aug-2007 11:41
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Pete, you may find these functions useful.

It is generally a good idea to use the Date type internally rather than strings. This prevents your DXL being broken by a user changing the Locale on their client.

Take a look at the Locale specific data handling routines (DOORS 8 onwards?) that allow you to convert dates to string representations for display in the format expected by the user.

-------------------------
Tony Goodman
http://www.smartdxl.com

Edited: 1-Aug-2007 at 12:20 by Tony Goodman
Report this to a Moderator Report this to a Moderator
 3-Aug-2007 16:46
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

Tony:

Thanks for your suggestions. I have looked over your code, and I understand what you mean. A million of thanks.

I am currently using DOORS 7.1. Usually, when I develop a program/function I usually just code concentrating on getting the overall behavior implemented. Then, I will take a look at what I wrote and optimize the code.

With the code I shared I use a lot of strings, which we all know is a big no no in DOORS due to the memory leaks (i.e. DOORS built-in string table mechanisms). I actually finished my function before I read your posts and mainly used a lot of Buffers with a few strings here and there to have optimized code.

I can share my code to all if they are interested.

- Pete

-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.