Changes
2 changed files (+61/-8)
-
-
@@ -22,8 +22,8 @@ @cInclude("time.h");@cInclude("sunriset.h"); }); latitude: f64 = c.DEFAULT_LATITUDE, longitude: f64 = c.DEFAULT_LONGITUDE, latitude: ?f64 = null, longitude: ?f64 = null, offset_hour: f64 = 0, twilight_angle: f64 = c.TWILIGHT_ANGLE_DAYLIGHT, target_time: ?c.time_t = null,
-
@@ -37,6 +37,9 @@ command: CommandOptions = .poll,pub const ParseArgsError = error{ UnknownArg, MissingValue, InvalidLatitudeFormat, InvalidLongitudeFormat, }; pub const ListOptions = struct {
-
@@ -178,12 +181,56 @@ self.utc = true;return; } if (std.mem.eql(u8, "--lat", arg) or std.mem.eql(u8, "--latitude", arg)) { const next = args.next() orelse { std.log.err("{s} option requires a value", .{arg}); return ParseArgsError.MissingValue; }; const lat = parseSuffixedLatitude(next) orelse std.fmt.parseFloat(f64, next) catch { return ParseArgsError.InvalidLatitudeFormat; }; if (self.latitude) |prev| { std.log.warn("Got more than one latitude, overwriting {d} with {d}", .{ prev, lat }); } self.latitude = lat; return; } if (std.mem.eql(u8, "--lon", arg) or std.mem.eql(u8, "--longitude", arg)) { const next = args.next() orelse { std.log.err("{s} option requires a value", .{arg}); return ParseArgsError.MissingValue; }; const lon = parseSuffixedLongitude(next) orelse std.fmt.parseFloat(f64, next) catch { return ParseArgsError.InvalidLongitudeFormat; }; if (self.longitude) |prev| { std.log.warn("Got more than one latitude, overwriting {d} with {d}", .{ prev, lon }); } self.longitude = lon; return; } if (parseSuffixedLatitude(arg)) |lat| { if (self.latitude) |prev| { std.log.warn("Got more than one latitude, overwriting {d} with {d}", .{ prev, lat }); } self.latitude = lat; return; } if (parseSuffixedLongitude(arg)) |lon| { if (self.longitude) |prev| { std.log.warn("Got more than one longitude, overwriting {d} with {d}", .{ prev, lon }); } self.longitude = lon; return; }
-
@@ -240,8 +287,8 @@var target_time: c.time_t = self.target_time orelse now; return c.runStruct{ .latitude = self.latitude, .longitude = self.longitude, .latitude = self.latitude orelse c.DEFAULT_LATITUDE, .longitude = self.longitude orelse c.DEFAULT_LONGITUDE, .offsetHour = self.offset_hour, .twilightAngle = self.twilight_angle, .nowTimet = now,
-
-
-
@@ -52,6 +52,16 @@ \\--debug Prints debug log, and shortens "wait" duration\\ to one minute. \\--utc Dates and times will use UTC rather than local time. \\ \\--lat <DEGREE>, --latitude <DEGREE> \\ Latitude of the point to calculate sunrise and sunset. \\ <DEGREE> must be a floating point number or a positive \\ floating point number with N or S suffix. \\ \\--lon <DEGREE>, --longitude <DEGREE> \\ Longitude of the point to calculate sunrise and sunset. \\ <DEGREE> must be a floating point number or a positive \\ floating point number with E or W suffix. \\ \\[Commands] \\poll Prints whether it's DAY or NIGHT. \\wait Sleep until sunrise and/or sunset, then exits.
-
@@ -69,10 +79,6 @@ \\EVENT TYPE Use "rise" for sunrise and "set" for sunset.\\ If this parameter is not set, sunwait targets both. \\OFFSET Time offset for sunrise and sunset time, towards noon. \\ Format must be "MM" (minutes) or "HH:MM". \\LATITUDE Angle in degree, positive floating point number. \\ Must have N or S suffix. \\LONGITUDE Angle in degree, positive floating point number. \\ Must have E or W suffix. \\ \\See man page for "sunwait(1)" for more. \\
-