Error in date elements, daylight
Summer dates in incoming control, which are recalculated before 1981 (with daylight saving time, I think).
eg. for example I enter 27.8.1960 - after saving I got 26.8.1960 (after the next save 25.8.1960 and so on) but 27.8.2010 - after saving it remained the same: 27.8.2010
"Winter dates": 04/27/1960 - after saving remained unchanged: 04/27/1960
looks like an ugly bug. how can I suppress this "calculation"?
(date format - Europe, I live in Germany. 8/27/1960 - August 27, 1960)
thanks for any help, uwe
<xp:inputText value="#{Auftrag.MF_GebDatum}" id="mF_GebDatum1" style="width:255px">
<xp:this.converter>
<xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
source to share
The problem you are struggling with is that Domino stores a datetime value with daylight information that does not exist for the dates you enter. The information for the time zone used comes from the current locale of the user and / or server.
Your date is stored in the field with the entered time zone (+ 2 hours GMT)
26.08.1960 00:00:00 CEDT
Domino interprets the stored value as it is without setting it
var ndt:NotesDateTime = session.createDateTime("26.08.1960 00:00:00 CEDT");
ndt.getGMTTime()
returns the correct datetime value adjusted by 2 hours for GMT
25.08.60 22:00:00 GMT
When converted back to Java, it is interpreted "correctly" that there was never daylight saving time in 1960, so it can only be set to 1 hour:
var ndt:NotesDateTime = session.createDateTime("26.08.1960 00:00:00 CEDT");
ndt.toJavaDate().toLocaleString()
will result in "08/25/1960 23:00:00" if you are in the CEDT time zone.
Currently, the only idea I have for easier workaround is to destroy the timezone information in the DateTime field. You can use this SSJS script for that:
<xp:this.querySaveDocument>
<![CDATA[#{javascript:
var doc:NotesDocument = document1.getDocument( true );
var items:java.util.Vector = doc.getItems();
var item:NotesItem;
var ndt:NotesDateTime;
var dt:java.util.Date;
for( var i=0; i<items.size(); i++){
item = items.get(i);
if( item.getType() === 1024 ){
ndt = item.getValueDateTimeArray().get(0);
ndt = session.createDateTime( ndt.getDateOnly());
item.setDateTimeValue( ndt );
ndt.recycle();
}
item.recycle();
}
}]]>
</xp:this.querySaveDocument>
source to share