HP Forums

Full Version: (71B) Approximate Time of Sunrise and Sunset
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Source:

Hewlett Packard "HP-65 Aviation Pac" 1974

The program SUNTIME approximates the time of sunset and sunrise based on a date in a general 365-day calendar, the person's location (longitude (east is negative, west is positive) and lattitude (north is positive, south is negative)), and the time zone.

Time Zone Table (United States/Mexico/Canada)
Hours from GMT:
Hawaii: Standard and Daylight: -10
Alaska: Standard: -9, Daylight: -8
Pacific: Standard: -8, Daylight: -7
Mountain: Standard: -7, Daylight: -6
Central: Standard: -6, Daylight: -5
Eastern: Standard: -5, Daylight: -4

Program SUNTIME
494 bytes, 1/24/2019
Code:

10 DESTROY T,E,D,A,Z,G,C
11 DESTROY S,S1,S2,S3
12 DESTROY O1,O2,O3,O,U1,U2,U3,U
14 DEGREES
16 INPUT "MONTH: ";M
20 INPUT "DAY: ";D
26 INPUT "LONG (E/W):D,M,S:";O1,O2,O3
27 O=O1+O2/60+O3/3600
30 INPUT "LAT (S/N):D,M,S:";U1,U2,U3
32 U=U1+U2/60+U3/3600
35 INPUT "TIME ZONE:";Z
40 T=.988*(D-1+30.3*(M-1))
45 E=.123*COS(T+87)-1/6*SIN(2*T+20)
50 C=-23.439*COS(T+10)
55 S=(O-ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
57 S1=IP(S)
59 S2=IP(FP(S)*60)
61 S3=FP(FP(S)*60)*60
65 DISP "Sunrise: ";S1;":";S2;":";S3 @ PAUSE
75 N=(O+ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
77 N1=IP(N)
79 N2=IP(FP(N)*60)
81 N3=FP(FP(N)*60)*60
85 DISP "Sunset: ";N1;":";N2;":";N3

Example:
Time: January 26 (Month = 1, Day = 26)
Place: Farifield, CA: 38°15′28″N 122°3′15″W
Time Zone: -8 (Standard)

Inputs:
MONTH: 1
DAY: 26
LONG: 122,3,15
LAT: 38,15,28
TIME ZONE: -8

Results:
Sunrise: 7 : 24 : 19.09497708
Susnet: 17 : 16 : 17.62419468
Reference URL's