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.

## MoonGetDate and subtract two dates

### Re: MoonGetDate and subtract two dates

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

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.

- Juan Carlos
**Posts:**865**Joined:**Mon Sep 06, 2010 1:02 pm

### Re: MoonGetDate and subtract two dates

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.

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.

### Re: MoonGetDate and subtract two dates

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: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.

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))
```

- Juan Carlos
**Posts:**865**Joined:**Mon Sep 06, 2010 1:02 pm

### Re: MoonGetDate and subtract two dates

Thank you your solution works. I haven't though in use DateToTimestamp with this result.

### Re: MoonGetDate and subtract two dates

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))
```

- Juan Carlos
**Posts:**865**Joined:**Mon Sep 06, 2010 1:02 pm

### Re: MoonGetDate and subtract two dates

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.

Sorry again I confuse the Wishlist for Designer with the Hollywood.

### Re: MoonGetDate and subtract two dates

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.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...

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?