Add time zone capability to buici clock
Hi Marc,
I did some changes to the buici-clock in order to be able to specify a time zone / country
whose date we want to display the time. The current syntax is the -tz switch followed by
the tz you wanna use in the zoneinfo/
As an example, if I wanna launch a buici-clock displaying the Phoenix time in the USA,
the command line will be:
buici-clock -tz America/Phoenix
I don't know what's the better way way to submit a patch, so I attach it at the end of this message.
Let me know if you are interested by merging such changes or not.
All the best,
-- rodrigo
diff --git a/clock.cxx b/clock.cxx
index fc9c03a..4ac4d73 100644
--- a/clock.cxx
+++ b/clock.cxx
@@ -91,6 +91,7 @@
//#define USE_LOCAL_GC // Cache our own GC
extern char* g_szApplication; // Name of application
+extern char* g_szTimeZone;
bool g_fQuit;
extern int g_fAsDesktop;
extern int g_fAsToolbar;
@@ -888,6 +889,12 @@ int do_clock (void)
int y = 0;
unsigned int dx = 100;
unsigned int dy = 100;
+ char buf[80];
+
+ if (g_szTimeZone) {
+ setenv(
+ putenv(buf);
+ tzset();
+ }
{
LDisplay display;
diff --git a/main.cxx b/main.cxx
index c5bb0df..b82d704 100644
--- a/main.cxx
+++ b/main.cxx
@@ -57,6 +57,7 @@ int g_fAsDock;
int g_fOverrideRedi
int g_showSecondHand = -1; // -1 means use the resource or default to true
char* g_szGeometry;
+char* g_szTimeZone = NULL;
OPTION rgOptions[] =
{
@@ -66,6 +67,7 @@ OPTION rgOptions[] =
{ "as-toolbar", OptSetInt, &g_fAsToolbar },
{ "override-
{ "show-second-hand", OptArg | OptSetInt, &g_showSecondHand },
+ { "tz", OptArg | OptSetString | OptAllDash, &g_szTimeZone },
{ "help", 0, NULL, do_usage },
{ "h", 0, NULL, do_usage },
@@ -102,6 +104,7 @@ int do_usage (OPTION*, const char*)
" --no-override Suppress window manager control by\n"
" inhibiting override-
" --show-
+" --tz Set the selected time zone\n"
" --version, -V Display version and copyright\n"
" --help, -h Usage message\n"
/* " (*) Default option\n" */
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- rosorio975
- Solved:
- Last query:
- Last reply: