MoonGetDate and subtract two dates

Feature requests for future versions can be voiced here
Post Reply
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

MoonGetDate and subtract two dates

Post by Juan Carlos »

In java there are two instructions:
blueMoonDate.GetTime() to get the Moon time useful to make a moon phase program or to make a converter of gregorian to muslin, hebrew calenders.

christmas.GetTime()-today.GetTime() is possible subtract two dates for example to make a days to christmas, or other programs as birthday reminder, etc.

It will be possible add for the next Hollywood version, because to get the date from system there are three ways but there aren't these possiblilites to work with the dates.
Thanks.
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: MoonGetDate and subtract two dates

Post by Flinx »

subtract two dates
At least this we had already. You can use the TimeStamp functions.

The exact calculation of the moon phases is a more difficult thing though, the mean synodic month is not enough there. If you need it now, you could use the formulas from here or try to port the javascript functions from the source code of this page to Hollywood.
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoonGetDate and subtract two dates

Post by Juan Carlos »

The example in the threat does not subtract the days left from the current date to the target date, for example days left until Christmas.
The moon, yes I have a little tool to know the moon phases, but java has an algorithm to use in more concrete cases, to calculate la moon phases or to make a converter to calendars, for example in what year are we in the Muslim or Hebrew calendar, since they are governed by the moon.
The question is possible add these two options as commands in Hollywood, subtract to dates to know the days or years, and the moon to make a moon calendar for example to grow plants.
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: MoonGetDate and subtract two dates

Post by Flinx »

The example in the threat does not subtract the days left from the current date to the target date, for example days left until Christmas.
Of course it does, if you use it in the right way. Here is an example, to make it easier to understand I have split the operations:

Code: Select all

Christmas$="24-Dec-2023 19:00:00"
ChristmasTimestamp=DateToTimestamp(UTCToDate(Christmas$))
TodayTimestamp=    DateToTimestamp(UTCToDate(GetDate(#DATELOCAL)))
SecondsUntilChristmas=ChristmasTimestamp-TodayTimestamp
DaysUntilChristmas=SecondsUntilChristmas/3600/24
DebugPrint("Days until christmas:",Int(DaysUntilChristmas))
; all in one line:
DebugPrint("Days until christmas:",Int((DateToTimestamp(UTCToDate(Christmas$))-DateToTimestamp(UTCToDate(GetDate(#DATELOCAL))))/86400))
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoonGetDate and subtract two dates

Post by Juan Carlos »

Thank you your solution works. I haven't though in use DateToTimestamp with this result.
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: MoonGetDate and subtract two dates

Post by Flinx »

By the way, I did copy the functions from my other post and did not think enough. The UTC conversion isn't useful in this case because we use local time, so you should remove it.

Code: Select all

DebugPrint("Days until christmas:",Int((DateToTimestamp(Christmas$)-DateToTimestamp(GetDate(#DATELOCAL)))/86400))
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoonGetDate and subtract two dates

Post by Juan Carlos »

Yes, the other problem is to use seconds as time unit for calculate the days until X date, because when it's been a day the result is 365, two days also 365 days, it will more perfect using days as java instead seconds...
Sorry again I confuse the Wishlist for Designer with the Hollywood.
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: MoonGetDate and subtract two dates

Post by Flinx »

Juan Carlos wrote: Tue Mar 21, 2023 3:03 pm the other problem is to use seconds as time unit for calculate the days until X date, because when it's been a day the result is 365, two days also 365 days, it will more perfect using days as java instead seconds...
I don't understand that. If you have a difference of more than 24 hours the result will be 1. If fewer then 0. You should always get a perfect result.
Look at the time, I did use 19:00:00, maybe you should set it to 00:00:00.
Can you give an example with the values that both have 365 days?
Post Reply