delphi的时间Ttime,Tdatetime的信息

本文介绍了Delphi中TTime和TDateTime的数据类型,TTime表示时间,其小数部分分别代表小时、分钟、秒和毫秒。TDateTime结合了日期和时间,整数部分表示自1899-12-30后的天数,小数部分表示一天中的时间比例。此外,还讨论了在不同编程语言中double类型的使用和TDateTime的负值处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一行 Ttime  =now的值  timetostr时间显示为15:08:50  双浮点数double类型,8字节

  小数点部分记录时间 0.6311428009 *24=15.1474272216  取整为15,  0.1474272216*60=8.845633296 取整8为分,

     0.845633296*60=50.73799776 取整为50为为秒,0.73799776*1000=737为毫秒。

  这是时间的计算方法。


    如果复制time,整数部分就为0了。


第三行 tDatetime  now的,Datetimetostr时间显示为2016-10-08 15:09:55, 双浮点数double类型,8字节

  小数点以后的表示的时间,如上计算。

  整数部分,表示的日期。自1899-12-30后的天数。


Tdate就是去掉小数部分的内容


网友:1:double数据类型是计算机四种基本类型之一,另外三个是:int,char,float 基本在每一种编程语言当中都有的实现。 2:在delphi当中double也是64位的。 3:c++当中double也是64位, 4:两种编程语言的double范围都是一样的


In Delphi, TDateTime is a type that maps to a Double. In C++, the TDateTime class corresponds to the Delphi TDateTime type.  

The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.  

Following are some examples of TDateTime values and their corresponding dates and times:

0  
12/30/1899 12:00 am  
2.75  
1/1/1900 6:00 pm  
-1.25  
12/29/1899 6:00 am  
35065  
1/1/1996 12:00 am  

To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive.  

When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 am on 12/29/1899 is –1.25, not –1 + 0.25, which would be –0.75. There are no TDateTime values between –1 and 0.

Note: Delphi 1.0 calculated the date from year 1 instead of from 1899. To convert a Delphi 1.0 date to a TDateTime value in later versions of the Delphi language, subtract 693594.0 from the Delphi 1.0 date.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值