Quantcast
Channel: LiveCode Forums
Viewing all articles
Browse latest Browse all 780

Getting Started with LiveCode - Experienced Developers • Day of Project (subtracting calendar days

$
0
0
Hi:

Imagine you started a project today at 00:00:00. We'll call that Day 1. At 1 second past midnight you'd be on day 2. You could calculate this easily using the difference in seconds. But what if you started your project today at 23:59:59. In calendar days you'd be on day 2 two seconds later. That's what I need. I need to know the day of a project in CALENDAR days given today and a start date.

Put differently let's suppose you start a project on a Monday. Any time during Monday should be day 1 and ANY time during Tuesday should be day two. It seems to me this must be a common problem and thus there is likely an elegant solution. Time zone are a thing for me since I have clients in many different time zones.

UPDATE: I have a solution. It's ugly. I'd be very happy if someone gave me the good looking / elegant / sophisticated version.

convert tProjectStarted to the internet date -- internet date format = Fri, 21 Jun 2024 09:51:36 +0700
put "00:00:00" into word 5 of tProjectStarted
convert tProjectStarted to seconds -- I believe this gets me the start of my day local time in seconds
put the seconds into tNow
return ceiling((tNow - tProjectStarted) / 86400) -- give me the correct day 0.0001 => Day 1 1.0001 => day 2

Bruce

Statistics: Posted by bbalmerTotalFluency — Fri Jun 21, 2024 3:15 am



Viewing all articles
Browse latest Browse all 780

Trending Articles