Script and scheduler for early sunrise (in Sweden)

Lights should turn on when the sun goes down. and
Lights should turn off when the sun comes up. and
Between 23.00 and 05.00 it the lights should turn OFF. and
Light should turn on after 05.00 if its still dark outside.

To do this create the following Script.

IF DAYTIME()
BEGIN
# during the day
SET (BIT/outdoorlighting) to 0
END
ELSE
BEGIN
# during the dark
IF HOUR() >22
SET (BIT/outdoorlighting) to 0
# dark and after 23:00 o'clock -> lights off
IF HOUR() >4
SET (BIT/outdoorlighting) to 1
# dark and before 5:00 o'clock -> lights on
IF (HOUR() >12) & (HOUR()<23)
SET (BIT/outdoorlighting) to 1
# dark and between 13:00 o'clock & 23:00 -> lights on
END

Now create a week scheduler.
Add an action that starts the script at the following times.
1. 05:00 Start
2. 23:00 Start
3. Sundown Start
4. Sunrise Start