# Use cron-plus to get tomorrow's sunrise and sunset?

**URL:** <https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248>\
**Category:** General\
**Created:** [26 September 2022 16:32 UTC](https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248 "2022-09-26T16:32:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorccan](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@lorccan](https://discourse.nodered.org/u/lorccan)\
**Post date:** [26 September 2022 16:32 UTC](https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248/1 "2022-09-26T16:32:42Z")

</div>

I'm feeding cron-plus this:

```auto
msg.payload = {
    "command": "describe",
    "expressionType": "solar",
    "location": "51.5100087,-2.5644624",
    "time": "2022-09-27 12:00",
    "solarType": "selected",
    "solarEvents": "sunrise,sunset",
    "timeZone": "Europe/London"
}

```

I was expecting to get tomorrow's (the hard-coded `time`) sunrise and sunset, but I am still getting the next sunset (today's) and sunrise (tomorrow's).

What am I doing wrong please?

(An alternative would be to get today's sunrise and sunset as they'll be near enough for my purposes but unless I call cron-plus before sunrise I still get the same output.)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 September 2022 17:12 UTC](https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248/2 "2022-09-26T17:12:30Z")

</div>

That is unexpected (assuming the time you used was after the sunset time returned)

Can you use a debug set to show the complete message coming out? Use the copy value button to grab the result & show us.

Also, try setting the `time` later than the last event (e.g. `"time": "2022-09-27 23:59"`) if it was not already

_I am not at a computer for a couple of days so cannot help more than ask you to try things.._

---

<div class="post-metadata">

**Author:** ![lorccan](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@lorccan](https://discourse.nodered.org/u/lorccan)\
**Post date:** [26 September 2022 17:29 UTC](https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248/3 "2022-09-26T17:29:54Z")

</div>

Here's the output (without changing the time):

```auto
{"command":{"command":"describe","expressionType":"solar","location":"51.5100087,-2.5644624","time":"2022-09-27 12:00","solarType":"selected","solarEvents":"sunrise,sunset","timeZone":"Europe/London","name":"schedule1","topic":"schedule1","payloadType":"default"},"result":{"solarState":{"direction":"rise","state":"Day","day":true,"night":false,"astrologicalTwilight":false,"nauticalTwilight":false,"civilTwilight":false,"goldenHour":false,"twilight":false,"morningTwilight":false,"eveningTwilight":false,"dawn":false,"dusk":false,"morningGoldenHour":false,"eveningGoldenHour":false},"nextEvent":"sunset","nextEventTime":"2022-09-27T17:59:58.580Z","nextEventTimeOffset":"2022-09-27T17:59:58.580Z","eventTimes":[{"event":"sunset","time":"2022-09-27T17:59:58.580Z","timeOffset":"2022-09-27T17:59:58.580Z"},{"event":"sunrise","time":"2022-09-28T06:06:49.960Z","timeOffset":"2022-09-28T06:06:49.960Z"}],"offset":0,"now":"2022-09-27T11:00:00.000Z","nowOffset":"2022-09-27T11:00:00.000Z","description":"Solar Events: 'sunrise, sunset'","nextDate":"2022-09-27T17:59:58.580Z","prettyNext":"sunset in 6 hours 59 minutes 58 seconds"}}

```

Setting `time` to `23:59` _does_ give the expected result, so I can work with that:

```auto
{"command":{"command":"describe","expressionType":"solar","location":"51.5100087,-2.5644624","time":"2022-09-27 23:59","solarType":"selected","solarEvents":"sunrise,sunset","timeZone":"Europe/London","name":"schedule1","topic":"schedule1","payloadType":"default"},"result":{"solarState":{"direction":"fall","state":"Night","day":false,"night":true,"astrologicalTwilight":false,"nauticalTwilight":false,"civilTwilight":false,"goldenHour":false,"twilight":false,"morningTwilight":false,"eveningTwilight":false,"dawn":false,"dusk":false,"morningGoldenHour":false,"eveningGoldenHour":false},"nextEvent":"sunrise","nextEventTime":"2022-09-28T06:06:49.960Z","nextEventTimeOffset":"2022-09-28T06:06:49.960Z","eventTimes":[{"event":"sunrise","time":"2022-09-28T06:06:49.960Z","timeOffset":"2022-09-28T06:06:49.960Z"},{"event":"sunset","time":"2022-09-28T17:57:39.954Z","timeOffset":"2022-09-28T17:57:39.954Z"}],"offset":0,"now":"2022-09-27T22:59:00.000Z","nowOffset":"2022-09-27T22:59:00.000Z","description":"Solar Events: 'sunrise, sunset'","nextDate":"2022-09-28T06:06:49.960Z","prettyNext":"sunrise in 7 hours 7 minutes 49 seconds"}}

```

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 November 2022 17:30 UTC](https://discourse.nodered.org/t/use-cron-plus-to-get-tomorrows-sunrise-and-sunset/68248/4 "2022-11-25T17:30:18Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
