日期项目中的错误,夏令时 [英] error in date items, daylight Saving

查看:122
本文介绍了日期项目中的错误,夏令时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在1981年之前的输入控件中的夏令时被重新计算(我认为夏令时)。



例如
例如我进入27.8.1960 - 保存后我得到了26.8.1960,(下一个保存25.8.1960之后等等)
但27.8.2010 - 保存后保持不变:27.8.2010



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



看起来像丑恶虫如何抑制这个计算?



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



感谢任何帮助,Uwe

 < xp:inputText value =#{Auftrag .MF_GebDatum}id =mF_GebDatum1style =width:255px> 
< xp:this.converter>
< xp:convertDateTime type =date>< / xp:convertDateTime>
< / xp:this.converter>
< / xp:inputText>


解决方案

您正在争取的问题是Domino存储日期时间值与您输入的日期不存在的夏令时信息。要使用的时区的信息来自当前用户区域设置和/或服务器。



您的日期存储在输入时区的字段中(+ 2h GMT)

  26.08.1960 00:00:00 CEDT 

Domino解释存储的值,而不进行调整

  var ndt:NotesDateTime = session.createDateTime(26.08.1960 00:00:00 CEDT); 
ndt.getGMTTime()

返回正确的datetime值,由GMT调整2小时

  25.08.60 22:00:00 GMT 

当转换回Java时,它被正确地解释为1960年以前从未有过夏令时,这就是为什么只能调整1小时:

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

将导致25.08.1960 23 :00:00,如果您在CEDT时区。



目前,我有一个简单的解决方法的唯一想法是在DateTime字段中杀死时区信息。为此,您可以使用此SSJS脚本:

 < 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; (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>


Summer dates in an input control which are before 1981 are recalculated (I think with daylight saving time).

e.g. e.g. I enter 27.8.1960 - after a save I got 26.8.1960, (after the next save 25.8.1960 and so on) but 27.8.2010 - after a save it stayed the same: 27.8.2010

"Winter dates": 27.4.1960 - after a save it stayed the same: 27.4.1960

looks like an ugly bug. how can I supress this "calculation"?

(date format is Europeen, I live in Germany. 27.8.1960 is 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>

解决方案

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>

这篇关于日期项目中的错误,夏令时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆