![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Alogrithm Approach on Presenting Dates Topic Summary: Created On: 30-Jul-2007 19:34 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: This function takes a year as a parameter and returns true if it is a leap year, otherwise false. | |
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Alogrithm Approach on Presenting Dates
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.