#312 closed enhancement (fixed)
An improvement for TextToDate function
Reported by: | imendez | Owned by: | Víctor de Buen Remiro |
---|---|---|---|
Priority: | lowest | Milestone: | |
Component: | TimeSetAlgebra | Version: | head |
Severity: | minor | Keywords: | |
Cc: |
Description
"TextToDate" function converts a text with the appropiate format into a Date.
It's the same that Eval(Text):
Date d1 = TextToDate("y2005m09d30");
Date d2 = Eval("y2005m09d30");
d1 = d2
I think "TextToDate" could have just the opposite working of "FormatDate"
function, with a second (and optional, of course) argument specifying an
appropriate format:
Date d1 = TextToDate("y2005m09d30");
Text t1 = FormatDate(y2005m09d30, "%cy%Ym%md%d");
Date d2 = TextToDate("y2005m09d30", "%cy%Ym%md%d");
Text t2 = FormatDate(y2005m09d30, "%cy%Ym%md%d");
Date d3 = TextToDate("20050930", "%c%Y%m%d");
Text t3 = FormatDate(y2005m09d30, "%c%Y%m%d");
Date d4 = TextToDate("09302005", "%c%m%d%Y");
Text t4 = FormatDate(y2005m09d30, "%c%m%d%Y");
where d1 = d2 = d3 = d4.
What do you think?
Regards
Change History (4)
comment:1 Changed 20 years ago by
comment:2 Changed 19 years ago by
Owner: | changed from danirus to Víctor de Buen Remiro |
---|
We are working about this bug
Thanks to report it
comment:3 Changed 19 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Bug has been fixed in CVS.
Please, read TextToDate description in order to check it's you need
You can test this new feature with this version of your test code
Date d0 = y2005m09d30;
Text f1 = "%cy%Ym%md%d";
Text t1 = FormatDate(d0, f1);
Date d1 = TextToDate(t1, f1);
Text f2 = "%c%Y-%m-%d";
Text t2 = FormatDate(d0, f2);
Date d2 = TextToDate(t2, f2);
Text f3 = "%c%Y%m%d";
Text t3 = FormatDate(d0, f3);
Date d3 = TextToDate(t3, f3);
Text f4 = "%c%m%d%Y";
Text t4 = FormatDate(d0, f4);
Date d4 = TextToDate(t4, f4);
comment:4 Changed 18 years ago by
bug_file_loc: | → http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000312 |
---|
Hi Iván,
Tol has now an approach to your porpouse, I think it's quite similar, but with
some differences.
It is the built-in function CTimeFromText(Text tmi, Text format).
The first difference is the Tol Type involved. You are talking about Date and
this function works with CTime, the new Tol type that will substitute Date in
the first stable Tol version (with Continuous Time, in alpha development just now).
The second difference is about the pattern you use to identify the given CTime.
The first argument contains the CTime string and the second the pattern that
will identify it, a character string that consists of field descriptors and text
characters in a POSIX compliant way.
The format supported now by Date is not POSIX compliant in several ways. We can
start a discussion about the convinience to apply the POSIX standard in Tol. You
can start reading more about CTimeFromText function in page 5 of
http://www.tol-project.org/docs/manualTC-es.pdf
English version is not ready yet.
Give me your impressions, and feel free to start a discussion in Tol-Project
lists (Desarrollo-Tol or Tol-Devel).
Cheers,
Daniel