[PATCH 14/23] wmsun: Add -12 command line option to use 12-hour clock.

Doug Torrance <[email protected]>
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
---
 wmsun/wmSun.1 |  3 +++
 wmsun/wmSun.c | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/wmsun/wmSun.1 b/wmsun/wmSun.1
index 95b5ba5..33cbd88 100644
--- a/wmsun/wmSun.1
+++ b/wmsun/wmSun.1
@@ -28,6 +28,9 @@ Set longitude of observer.
 Set the difference beteeen UT and LT. Useful when you want to show the
 Sunrise/Sunset at a remote lat/lon without resetting your clock.
 .TP
+.B \-12
+Use 12-hour clock.
+.TP
 .B \-date <yyyymmdd>
 Set the date to show sunrise/sunset for.
 .SH EXAMPLES
diff --git a/wmsun/wmSun.c b/wmsun/wmSun.c
index 249eb3c..f3fc778 100644
--- a/wmsun/wmSun.c
+++ b/wmsun/wmSun.c
@@ -108,6 +108,7 @@ int	UseUserTimeDiff = 0;
 int	UseUserDate = 0;
 long	UserDate;
 double 	Glat, Glon, SinGlat, CosGlat, TimeZone, UserTimeDiff;
+int	TwelveHour = 0;
 
 
 int	xDigit[11] = {8, 18, 27, 37, 46, 55, 64, 74, 83, 92, 102};
@@ -225,6 +226,11 @@ int main(int argc, char *argv[]) {
 		if (LTRise > 0.0){
 	    	    val = LTRise;
 	    	    H = (int)val; val = (val-H)*60.0;
+		    if (TwelveHour) {
+			H = H % 12;
+			if (H == 0)
+			    H = 12;
+		    }
 	    	    M = (int)val;
 	    	    copyXPMArea(xDigit[H/10], 73, 7, 9, 17, 13);
 	    	    copyXPMArea(xDigit[H%10], 73, 7, 9, 17+7, 13);
@@ -239,6 +245,11 @@ int main(int argc, char *argv[]) {
 		if (LTSet > 0.0){
 	    	    val = LTSet;
 	    	    H = (int)val; val = (val-H)*60.0;
+		    if (TwelveHour) {
+			H = H % 12;
+			if (H == 0)
+			    H = 12;
+		    }
 	    	    M = (int)val;
 	    	    copyXPMArea(xDigit[H/10], 73, 7, 9, 17, 40);
 	    	    copyXPMArea(xDigit[H%10], 73, 7, 9, 17+7, 40);
@@ -347,6 +358,10 @@ void ParseCMDLine(int argc, char *argv[]) {
 	    UseUserDate = 1;
 	    UserDate = atoi(argv[++i]);
 
+	} else if (!strcmp(argv[i], "-12")){
+
+	    TwelveHour = 1;
+
 	} else {
 	    printf("\nwmSun version: %s\n", WMSUN_VERSION);
 	    printf("\nusage: wmSun [-display <Display>] [-lat <Latitude>] [-lon <Longitude>] [-h]\n\n");
@@ -355,6 +370,7 @@ void ParseCMDLine(int argc, char *argv[]) {
 	    printf("\t-lat <Latitude>\t\tObservers Latitude. Positive to the west.\n");
 	    printf("\t-lon <Longitude>\tObservers Longitude.\n");
 	    printf("\t-td <Delta Time>\tUser defined difference between UT an LT (hrs).\n");
+	    printf("\t-12\t\t\tUse 12-hour clock.\n");
 	    printf("\t-h\t\t\tDisplay help screen.\n\n");
 	    exit(1);
 	}
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.