0

重新计算 1981 年之前的输入控件中的夏季日期(我认为是夏令时)。

例如,我输入 27.8.1960 - 保存后我得到 26.8.1960,(下一次保存后 25.8.1960 等等)但是 27.8.2010 - 保存后它保持不变:27.8.2010

“冬季日期”:27.4.1960 - 保存后保持不变:27.4.1960

看起来像一个丑陋的错误。我怎样才能抑制这种“计算”?

(日期格式是欧洲,我住在德国。27.8.1960 是 1960 年 8 月 27 日)

感谢您的帮助,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>
4

1 回答 1

0

The problem you are fighting with is that Domino stores a datetime value with the daylight saving information which does not exists for the dates you are entering. The information for the timezone to use comes from the current user locale and / or the server.

Your date is stored in a field with the timezone it was entered (+2h GMT)

26.08.1960 00:00:00 CEDT

Domino interprets the stored value as it is, without adjusting 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

While converted back to Java, it is interpreted "correctly" that there was never a daylight saving time in 1960, that's why it will be adjusted only by 1 hour:

var ndt:NotesDateTime = session.createDateTime("26.08.1960 00:00:00 CEDT");
ndt.toJavaDate().toLocaleString()

will result in "25.08.1960 23:00:00" if you are in the CEDT timezone.

Currently the only idea I have for an easy workaround is to kill the Timezone information in the DateTime field. To do this you can use this SSJS script:

<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>
于 2013-01-14T10:33:54.347 回答