显示时间功能 [英] Displaying Time Function

查看:102
本文介绍了显示时间功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在显示时间的功能中,时间晚一小时.
功能:

In a function that displays time, The time is one hour behind.
The function:

s_ct1980 = CTime(1980, 1, 1, 0, 0, 0);



其中CTime的格式=(int年,int月,int日,int小时,int分钟,int秒,int dst = -1)

即:最后一个变量用于夏令时,但默认为-1,因此不包含在上面的函数中.但是如果我在函数中强制值,即:
CTime(1980, 1, 1, 0, 0, 0, 1),那么小时又向后退了一个小时.如何将其提前一个小时?



Where The format of CTime=(int year, int month, int day, int hour, int min, int sec,int dst=-1 )

ie: the last variable is for daylight saving, but it is defaulted to -1 and hence not included in the above function. But if I force values in the function ie:
CTime(1980, 1, 1, 0, 0, 0, 1) , then the hour is going one more hour backwards. How do I put it an hour forward?

推荐答案

请参见
See CTime()[^] for a full explanation.


MSDN说:

在创建CTime对象时,请将nDST参数设置为0以表示标准时间生效,或者将其设置为大于0的值以表示夏令时生效,或者将其设置为小于零的值以使其生效. C运行时库代码将计算标准时间还是夏令时.

When creating a CTime object, set the nDST parameter to 0 to indicate that standard time is in effect, or to a value greater than 0 to indicate that daylight savings time is in effect, or to a value less than zero to have the C run-time library code compute whether standard time or daylight savings time is in effect.


在构造函数"下表示:

CTime(int,int,...);从本地时间组件构造一个CTime对象,每个组件都限制在以下范围内:
[已删除表格]
该构造函数将适当地转换为UTC.

CTime( int, int, ...); Constructs a CTime object from local time components with each component constrained to the following ranges:
[table edited out]
This constructor makes the appropriate conversion to UTC.


那么它认为它在哪个时区呢?结果将取决于此,因为它将结果从本地时间转换为UTC.

彼得


So what timezone does it think it is in? The result will depend on that, since it''s converting the result from local time to UTC.

Peter


Added +1 to the variable that holds hour.

Though this is a temporary solution,(Have to change this when the daylight saving ends) it solves my problem.


这篇关于显示时间功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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