![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Date Formats Topic Summary: Created On: 9-Apr-2008 22:33 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Did some experimenting and have come up with the following rules governing how the 'data format' turns a date into a string, via the new v8.0 'stringOf(Date dat, string Format)' perm.
Format looks for lower case 'y', upper case 'M', and lower case 'd'. Everything else it transfered as is to the output string (consider them super delimiters). y - One or two digit year '8' for 2008, '99' for 1999. yy - two-digit year, zero padded '08' for 2008 yyy - same as yyyy yyyy - 4 digit year '2008'. yyyyy - same as yyyy. Additional y's are ignored. M - One or two digit month, '4' for April or '11' for November MM - two digit month, zero padded, '04' for April MMM - three letter month 'Apr' for April MMMM - full month spelled out 'April' or 'November'. MMMMM - same as MMMM. Additional M's are ignored d - one or two digit day, '1' for the 1st, '23' for the 23rd dd - two digit day, zero padded. '01' for the 1st ddd - three letter day of week 'Fri' for Friday, 'Sun' for Sunday dddd - full spelled out day of week 'Friday' or 'Sunday' ddddd - same as dddd. Additional ds are ignored You can repeat the above, so 'ddd, ddMMyyydddd' will look like 'Fri, 11042008Friday'. I notice there's no way to print '04Apr', as that would require 2-M and 3-M which looks like 5-Ms which is treated as 4-Ms which looks like 'April'. For 11-April-2008, this string: ddd xxdd-MM-yyMMdxXmyTT should produce: Fri xx11-04-080411xX48TT. Good luck with that. Here's some good formats: yyyyMMdd - 20080411 good for alpha sorting yyyy-MM-dd 2008-04-11 Good for alpha sorting, easy to read, put this in file names dd-MMM-yyyy 11-Apr-2008 Unambigous ddd, dd-MM-yy Fri, 11-04-08. - Louie |
|
![]() |
|
![]() |
|
This is all great stuff Louie, just what I need, but unfortunately we are still running a lot of DOORS 7.1 instances. Can a similar thing be done in 7.1?
Ideally I wish to find the current day of the week i.e. Sunday, Saturday etc. As I need to make sure that I append a weekly date to a file that is consistent - in VB you can do Format(Now(), "dddd") which gives you a day in string format, which you can use to determine how many days (ints) to add to the current date to get your consistent weekly date. This sounds complicated I know, but I haven't explained it well sorry. The 8.1 functionalities are ideal - how annoying. |
|
![]() |
|
![]() |
|
Attached find fDayOfWeek and fFormatDate.
fDayOfWeek: Got the basis for this code here on the forums, and tweaked it. This is the function I use in v7.1 to determine the day of the week. fFormatDate will not work on your machine since its tied to my massive library, you'll have to tweak it: [1] I'd assume 'Format zero' and get rid of the call parameter [2] fIsSubStr (sub-string) and fGetOffset should probably be replaced with clever RegExp to find the colon (fIsSubStr) and to locate the two in the date format (fGetOffset). Maybe one of the clever RegExp folks here can tweak this function to make it useable by all. - Louie |
|
![]() |
|
![]() |
|
Great job Louie ! (As usual
![]() In addition, I noticed that if your "Date" contains a time, it will be displayed after your formated string regardless your format parameter. It doesn't seem to be any format delimiter for time (that could for instance allow to display time before date, or remove columns, and so on). Does somebody have anything to interpret h, hh, m, mm, s and ss delimiters ? ------------------------- E. Piallat CeBeNetwork |
|
![]() |
|
![]() |
|
Thats great stuff.
I wish DOORS had a concept of 'dates' rather than integers. When you want to know, lastweek = currentdate - 6 i.e. 6 days previous to current date, this goes wrong when you are <6 days into the month, as you end up with zero !! I guess you need to know the month and how many days in it. I imagine you could use a similar setup to what you have used for your months. |
|
![]() |
|
![]() |
|
Don't underestand your 'lastweek = currentdate - 6" reference. If you want to know the date 6 days ago, yikes, you'd do something like this:
int iLastWeek = intOf(today()) - 6*secsInADay //=60*60*24 Date datLastWeek = dateOf(iLastWeek) // looks like 04-14-08 10:12:30 // strip off seconds: string sLastWeek = fFormatDate(datLastWeek) // looks like '2008-Apr-04' datLastWeek = sLastWeek - Louie In v8 I think there's a native strip-the-seconds function, in which case you don't need fFormatDate. |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Date Formats
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.