什么是近时间? [英] What is the near time ??

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

问题描述



嗯,伙计们我有项目(  美食时报 )好吗?我有5次食物

Well,, guys i have project for ( Food Times ) ok ? and i have 5 times for food


(  Morning  ,  Midday  ,  Sunset  ,   晚上 ,  午夜 )

Morning , Midday , Sunset , Night , Midnight )



  • 上午:03:20 AM

  • 中午:12:05 PM

  • 日落:03:46 PM

  • 晚上:07:33 PM

  • 午夜:08:28 PM
  • Morning : 03:20 AM
  • Midday : 12:05 PM
  • Sunset : 03:46 PM
  • Night : 07:33 PM
  • Midnight : 08:28 PM


现在我需要把计时器检查它与数组时间匹配当前时间如果他发现数组的任何时间到PC的当前时间他会显示一条消息

now i need put timer to check It matches the current time with array times If he finds any time of the array to the current time of PC he displays a message





推荐答案


现在我需要检查当前时间的近似时间是什么?

now i need check What is the near time of the current time ??

datetime对象支持简单的数学运算。因此,您可以从另一个中减去一次以找到差异。

The datetime object supports simple maths operations.  You can therefore subtract one time from another to find the difference.

如果您发现当前时间与每个事件时间之间的差异,那么您可以检测哪个(绝对)差异是最小的。 请参阅:

https://msdn.microsoft.com/en-us/library/1905yhe2(v = vs.110).aspx

If you find the difference between the current time and each of those event times, then you can detect which (absolute) difference is the smallest.  See:
https://msdn.microsoft.com/en-us/library/1905yhe2(v=vs.110).aspx

使用具有日期时间的数学运算符您可能需要确保为对象制作了正确反映相关时间的日期。例如,如果当前时间是00:01,那么您将需要包含20:28比较中之前的
天。 那些数据es可能是当前日期,也可能是正确反映所需关系的人为日期。 也许最简单的方法是使用当前日期时间的今天日期,然后创建前一天的
a 20:28日期时间,以及第二天的03:20日期时间,以及5个日期时间今天。

To use maths operators with a datetime you may need to ensure that you have manufactured a date for the object that correctly reflects the relevant time.  For instance, if the current time is 00:01 then you will need to include  20:28 on the previous day in the comparisons.  Those dates might be the current date, or might be an artificial date that correctly reflects the required relationship.  Perhaps the simplest way to do that is to use today's date for the current datetime, and then create a 20:28 datetime for the previous day, and an 03:20 datetime for the next day, in addition to the 5 datetimes for today.


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

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