Recent

Author Topic: The problem with time: ((  (Read 2880 times)

abmservice

  • Jr. Member
  • **
  • Posts: 69
The problem with time: ((
« on: July 27, 2014, 03:42:57 pm »
How to detect that someone was at work between 22:00 and 6:00. I've never dealt with calculations of the time so I do not know how to go about it?

Bart

  • Hero Member
  • *****
  • Posts: 5677
    • Bart en Mariska's Webstek
Re: The problem with time: ((
« Reply #1 on: July 27, 2014, 04:10:55 pm »
There is a DateUtils unit (IIRC) that has functions for that I guess.

Bart

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: The problem with time: ((
« Reply #2 on: July 27, 2014, 04:50:12 pm »
with time alone you can't with date and time you can because after 23:99 the date changes.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

abmservice

  • Jr. Member
  • **
  • Posts: 69
Re: The problem with time: ((
« Reply #3 on: July 27, 2014, 05:08:53 pm »
I know that. just do not know how to solve.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: The problem with time: ((
« Reply #4 on: July 27, 2014, 05:14:41 pm »
How to detect that someone was at work between 22:00 and 6:00. I've never dealt with calculations of the time so I do not know how to go about it?

Code: [Select]
  (timeof(now)>22/24.0) or (timeof(now)<6/24.0)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: The problem with time: ((
« Reply #5 on: July 27, 2014, 05:19:02 pm »
Code: [Select]
  (myvar >= (today+EncodeTime(22,00,00,00))) and (Myvar < (today+1+EncodeTime(06,00,00,00)))
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018