delphi 判断两个时间差是否在一个指定范围内
WithinPastYears、WithinPastMonths、WithinPastWeeks、WithinPastDays ... 判断两个时间差是否在一个指定范围内
DateUtils.WithinPastYears();
DateUtils.WithinPastMonths();
DateUtils.WithinPastWeeks();
DateUtils.WithinPastDays();
DateUtils.WithinPastHours();
DateUtils.WithinPastMinutes();
DateUtils.WithinPastSeconds();
DateUtils.WithinPastMilliSeconds();
--------------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses DateUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
t1,t2: TDateTime;
b: Boolean;
begin
t1 := StrToDateTime('2009-5-20 11:22:33');
t2 := StrToDateTime('2009-5-21 11:22:33');
{两个时间差是否在 24 年内}
b := WithinPastYears(t1, t2, 24); //True
{两个时间差是否在 24 个月内}
b := WithinPastMonths(t1, t2, 24); //True
{两个时间差是否在 24 个周内}
b := WithinPastWeeks(t1, t2, 24); //True
{两个时间差是否在 24 天内}
b := WithinPastDays(t1, t2, 24); //True
{两个时间差是否在 24 个小时内}
b := WithinPastHours(t1, t2, 24); //True
{两个时间差是否在 24 分钟内}
b := WithinPastMinutes(t1, t2, 24); //False
{两个时间差是否在 24 秒内}
b := WithinPastSeconds(t1, t2, 24); //False
{两个时间差是否在 24 毫秒内}
b := WithinPastMilliSeconds(t1, t2, 24); //False
// ShowMessage(BoolToStr(b, True));
end;
end.
delphi 判断两个时间差是否在一个指定范围内的更多相关文章
- delphi计算两个时间差
uses DateUtils; var S1, S2: string; T1, T2: TDateTime; D, H, M, S: Integer; Value: Int64; begin S1 : ...
- Spring Data MongDB空间索引(判断一个点Point是否在一个区域Polygon内)
这里要连接MongoDB数据库,在配置文件里:spring.data.mongodb.uri = mongodb://root:root@localhost:27017/happy 两个root分别是 ...
- Python 射线法判断一个点坐标是否在一个坐标区域内
class Point: lng = '' lat = '' def __init__(self, lng, lat): self.lng = lng self.lat = lat # 求外包矩形 d ...
- 判断IP地址是否在指定范围内的方法
比如给定一个ip段:127.0.0.1 ~ 127.0.0.255,我们想判断一个给定的ip地址是否在此段内,可以先将ip地址转换成整数,然后整数比较大小就很容易了. 例如: 127.0.0.1 = ...
- GetParent、SetParent、MoveWindow - 获取、指定父窗口和移动窗口,IsChild - 判断两个窗口是不是父子关系
提示: SetParent 应该 Windows.SetParent, 因为 TForm 的父类有同名方法. //声明: {获取父窗口句柄} GetParent(hWnd: HWND): HWND; ...
- 自己设计一个日期类,可以输入年月日作为构造时的参数,如果不使用参数,则设定为1900年1月1日;编写一个方法equals判断两个日期是否相等;另一个方法compareTo可以进行日期之间的比较,返回两个日期之间相差的天数.
import java.util.*; import java.lang.Math; class Date1{ private int year; private int month; private ...
- C语言位操作--判断两整数是否异号
判断两整数是否异号: int x, y; //输入比较的两数 bool f = ((x ^ y) < 0); // 返回真,当且仅当x与y异号 说明:当x.y异号,x与y的最高位分别为0和1,取 ...
- 一个diff工具,用于判断两个目录下所有的改动(比较新旧版本文件夹)
需求: 编写一个diff工具,用于判断两个目录下所有的改动 详细介绍: 有A和B两个目录,目录所在位置及层级均不确定 需要以B为基准找出两个目录中所有有改动的文件(文件或内容增加.修改.删除),将有改 ...
- C# 通过比对哈希码判断两个文件内容是否相同
1.使用System.security.Cryptography.HashAlgorithm类为每个文件生成一个哈希码,然后比较两个哈希码是否一致. 2. 在比较文件内容的时候可以采用好几种方法.例如 ...
随机推荐
- 使用Turbine对集群进行监控
为什么要使用Turbine Turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过turbine来监控集群下hystrix的me ...
- 使用Maven进行依赖管理和项目构建
什么是Maven 1 依赖的管理:仅仅通过jar包的几个属性,就能确定唯一的jar包,在指定的文件pom.xml中,只要写入这些依赖属性,就会自动下载并管理jar包. 2 项目的构建:内置很多的插件与 ...
- Codeforces 631E 斜率优化
题意:给你一个数组,你可以选择数组中的一个数,把它插入数组的其它位置,问∑ i * a[i]的最大值为多少? 思路:设dp[i]表示把第i个数向左边插入可以获得的最大增量,我们假设向左边插入,设插入的 ...
- 笔记59 Spring+Hibernate整合(二)
一.项目结构 二.创建表 数据库中只有一张表,stock,三个字段:stock_id.stock_code和stock_name. CREATE TABLE `stock` ( `STOCK_ID` ...
- eclipse Tomcat8.0端口占用报错和发布路径修改
实际上我是eclipse莫名其妙调试时崩了,结果再启动也无法启动tomcat报端口占用错 修改server.xml里的端口号不是好方法,改完运行报 “ 对不起! 这里不是Web服务器” 后来研究发 ...
- redux combineReducers的用法
给这种 state 结构写 reducer 的方式是分拆成多个 reducer,拆分之后的 reducer 都是相同的结构(state, action),并且每个函数独立负责管理该特定切片 state ...
- Python的历史及介绍
Python的诞生 Python的创始人吉多·范罗苏姆(Guido van Rossum),在1989年12月的圣诞节期间,为了打发时间,决定开发一种新的脚本解释程序,作为ABC语言的继承. 现在,p ...
- spark算子之Aggregate
Aggregate函数 一.源码定义 /** * Aggregate the elements of each partition, and then the results for all the ...
- js基本算法
一.阶乘(递归思想) // 计算阶乘 function factorial(n) { if (n === 1) { return 1 } return n * factorial(n - 1) } 二 ...
- MySQL - primary key PK unique key,key PK index
primary key PK unique key 总结 primary key = unique + not null 主键不能为空每个字段值都不重复,unique可以为空,非空字段不重复 uniq ...