Bug (sort of) with TextToTime on web

If you try to use a Date field value directly in a date calculation (eg. @Now - MyDateField), you will get an error. This will show both in the browser and the log. No problem.

If you try to convert the date first (@Now - @TextToTime(MyDateField)), when you save the document, you are returned to the last view or the database home. Everything looks okay, but the document is never saved! There is no error message anywhere, but your changes are gone!

Now it appears the correct (or at least working) forumla is actually Now - @TextToTime(@Text(MyDateField)). However, it seems like either the other forumula should work as well, or you should get a visible error. Especially when you can have a computed field with @TextToTime(MyDateField) and the value is displayed as expected. Silently failing the save operation is not cool!

Subject: Bug (sort of) with TextToTime on web

"If you try to use a Date field value directly in a date calculation (eg. @Now - MyDateField), you will get an error. "

Works like a charm for me. Can you provide some detailed instructions on how to force this error?

Subject: RE: Bug (sort of) with TextToTime on web

Say you have a date field set to a date string on the web (eg. 26/12/1977). If you have another field that is computed to @Now - MyDateField, you will receive an internal server error when the form is loaded (at least, I do). In the log is the message “Incorrect data type for operator or @Function: Time/Date expected”.

Subject: RE: Bug (sort of) with TextToTime on web

No way. Make sure, that both fields are date fields and your ready to fly.

Of course, MyDateField MUST have a default date in this scenario. Any empty field is initially text, regardless of the type you choose in Designer …

Subject: RE: Bug (sort of) with TextToTime on web

Here is a simple form I can use to replicate the problem.

Field

Name: DateTest

Type: Editable Date/Time

Default Value: “26/12/1977”

And directly beneath this…

Computed Text

Formula: @Now - DateTest

Not sure what I am doing wrong. This seems pretty simple.

Subject: RE: Bug (sort of) with TextToTime on web

→ Default Value: “26/12/1977” ←

Well, that’s text, not a date. :smiley:

In contrast to that, this IS a date:

[26/12/1977]

Subject: RE: Bug (sort of) with TextToTime on web

Right, so back to my original post (which was obviously worded poorly). In this case, I did expect an error.

My point about the problem with @TextToTime still stands though. Can you replicate my issue?

Subject: RE: Bug (sort of) with TextToTime on web

Not sure if I really got your current setup right, but:

@TextToTime

will throw an error, if the argument is a date already. It will only accept text inputs. That’s why R6 brought us @ToTime. Does the same, but leaves a date/time value as it is, without freaking out about it.

Subject: RE: Bug (sort of) with TextToTime on web

I will try @ToTime and see if the behavior is the same (on Monday…).

My problem with all of this is that @TextToTime freaks out, but doesn’t raise an error. Its very hard to find the point of failure in this case.

Subject: RE: Bug (sort of) with TextToTime on web

O.K., I think I can finally reproduce your original observation.

If you define MyDateField as a date field, but (incorrectly, I have to state) provide a text constant as default value, and you have another date field, that uses a calculation based on @TextToTome(MyDateField), then on submit you are returned to the database’s home, no error is displayed, the document is not saved. This does not happen, if you leave the default value blank and submit without entering anything into MyDateField.

However, it DOES happen as well, if you enter a valid date into MyDateField prior to submitting, if the default was blank. Correct date format or day component within the range of valid month values doesn’t matter.

@ToTime does take care of it all (in a way), I think.

If you leave the default value blank, you will receive an “Unable to interpret Time or Date” error.

If you provide the default as text and submit, the document is saved.

If user modifies the default date or if you provide a date time value as default, everything works as it should.

So, all in all, I think it’s debatable if you should call it a bug or not. The most likely trouble causing scenario is, to leave the date field blank, rely on the user to input a date and use a formula containing @TextToTime for date processing. One would be tempted to assume, that this should work. Not even an input translation of @ToTime(@ThisValue) does any good here, nor does a WQS agent.

It’s annoying for sure, but capturing dates in regular inputs is not a good practice anyway, so probably the issue is rarely observed.

Subject: RE: Bug (sort of) with TextToTime on web

Subject: Bug (sort of) with TextToTime on web

Subject: RE: Bug (sort of) with TextToTime on web

Sorry, just noticed your post. I will check this out on Monday as well. Thanks.

Subject: RE: Bug (sort of) with TextToTime on web

Willy, the term DOM is ambiguous. I must, that it is not clear to me from your posting, to which you are referring.

Subject: RE: Bug (sort of) with TextToTime on web

Subject: RE: Bug (sort of) with TextToTime on web

HTTP task processes the DOM and sends it to the browser? You keep confusing me.

Does it make a difference, if Domino implements DOM objects and methods to build HTML documents?

Does Domino care, if the user agent implemntes DOM objects and methods to manipulate HTML documents?

Does the HTTP response look different, if it does?

Subject: RE: Bug (sort of) with TextToTime on web

Subject: RE: Bug (sort of) with TextToTime on web

So, you ask me to call you Mr. Lorenzo? As you like.

Here’s how to put it much more plain: What Andrew describes only happens, if the database property to use JavaScript when generating pages is set.

If it is not, there will still be an error under the conditions described, but it will be displayed.

Subject: RE: Bug (sort of) with TextToTime on web

Subject: RE: Bug (sort of) with TextToTime on web

Actually, the only thing that I don’t agree to, is your synonymous usage of the DOM and HTML structure.

Here is why: According to W3C specification, DOM is defined as an API for accessing a document, not the document itself.

Quote:

“The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.”

All, that Domino generates, is an HTTP response that carries HTML (generated by the once so called “Domino engine”) in its body (like any other HTTP server). This HTML definitely defines a structure and you can argue, that there is always implicitly something like a “DOM”. After the browser has parsed and tokenized the HTML, there surely is some explicitly Object Model for use by its rendering engine. But it is not necessarily identical to the DOM per W3C specification.

From my point of view, the HTML source, the HTML structure and the DOM are three distinct things, even if heavily related. One of my favorite samples, I keep boring people to death with, is that of an odd looking, but completely valid HTML file:

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

title>I’m valid/title>

body>

table>tr>td>I really am/table>

/body>

(opening angle brackets removed intentionally)

The HTML source is stripped to the absolute minimum. Still, the document structure is more complex: While e.g. html and head TAGS are optionally, the html and head ELEMENTS are not, so they will be there for the browser. But they will even be there, if the browser in question does know nothing about and does provide no implementation of W3C DOM in any programming language. Would it make sense to call the structure a DOM then? Maybe, for the sake of convenience. But it would not be W3C DOM for HTML (Level 1? Level 2? Level 3?) then.

The general limitation of the DOM is, that there are no data types other then text. But this is rather based on the limitation of HTTP requests and HTML structure (if not worked around with something like XForms).

One last note on this special case: The slightly weired behavior of the (Notes) document not being saved an no error being generated only occurs with Domino generated JavaScript, indeed. I did test that yesterday. If you use a standard submit button or generate your own JS submit button (with Domino JS generation disabled), this does not occur. So I would conclude, that this (minor) issue is rather with the Domino generated JS.

As my testing included IE6 and FF2 only, it could in theory still be related to the DOM implementation of these browsers, but … no, I don’t think so, and I’m not keen in further investigation. A properly designed page will not suffer from this problem, and that’s all I need to know.