]> git.mxchange.org Git - flightgear.git/commitdiff
Clock also able to report local time.
authorcurt <curt>
Thu, 17 Nov 2005 22:07:27 +0000 (22:07 +0000)
committercurt <curt>
Thu, 17 Nov 2005 22:07:27 +0000 (22:07 +0000)
src/Instrumentation/clock.cxx
src/Instrumentation/clock.hxx

index 736beff38e42d19d6908cabc977db757c8ca17d8..6a584bb5812dcac3099d7b2e0121c68932747eb0 100644 (file)
@@ -19,6 +19,7 @@ Clock::Clock ( SGPropertyNode *node )
       _indicated_sec(0),
       _indicated_min(0),
       _indicated_hour(0),
+      _local_hour(0),
       _standstill_offset(0),
       name("clock"),
       num(0)
@@ -70,8 +71,10 @@ Clock::init ()
     _sec_node = node->getChild("indicated-sec", 0, true);
     _min_node = node->getChild("indicated-min", 0, true);
     _hour_node = node->getChild("indicated-hour", 0, true);
+    _lhour_node = node->getChild("local-hour", 0, true);
     _string_node = node->getChild("indicated-string", 0, true);
     _string_node1 = node->getChild("indicated-short-string", 0, true);
+    _string_node2 = node->getChild("local-short-string", 0, true);
 }
 
 void
@@ -90,6 +93,12 @@ Clock::update (double delta_time_sec)
     int min = t->tm_min;
     int sec = t->tm_sec;
 
+    // compute local time zone hour
+    int tzoffset_hours = globals->get_time_params()->get_local_offset() / 3600;
+    int lhour = hour + tzoffset_hours;
+    if ( lhour < 0 ) { lhour += 24; }
+    if ( lhour >= 24 ) { lhour -= 24; }
+
     long gmt = (hour * 60 + min) * 60 + sec;
     int offset = _offset_node->getLongValue();
 
@@ -130,12 +139,18 @@ Clock::update (double delta_time_sec)
     _string_node->setStringValue(_indicated_string);
     sprintf(_indicated_short_string, "%02d:%02d", hour, min);
     _string_node1->setStringValue(_indicated_short_string);
+    sprintf(_local_short_string, "%02d:%02d", lhour, min);
+    _string_node2->setStringValue(_local_short_string);
     _is_serviceable = true;
 
-   _indicated_min = min;
+    _indicated_min = min;
     _min_node->setLongValue(_indicated_min);
-   _indicated_hour = hour;
+    _indicated_hour = hour;
     _hour_node->setLongValue(_indicated_hour);
+    _local_hour = lhour;
+    _lhour_node->setLongValue(_local_hour);
+
+    
 }
 
 
index 19c72af9caf4e395fb36aee38466642cfe19f84c..b9d0a7da29a757e6d642829b6d13c4038ac5c1c9 100644 (file)
@@ -50,8 +50,10 @@ private:
     long _indicated_sec;
     long _indicated_min;
     long _indicated_hour;
+    long _local_hour;
     char _indicated_string[16];
     char _indicated_short_string[16];
+    char _local_short_string[16];
     long _standstill_offset;
 
     string name;
@@ -61,9 +63,11 @@ private:
     SGPropertyNode_ptr _offset_node;
     SGPropertyNode_ptr _sec_node;
     SGPropertyNode_ptr _hour_node;
+    SGPropertyNode_ptr _lhour_node;
     SGPropertyNode_ptr _min_node;
     SGPropertyNode_ptr _string_node;
     SGPropertyNode_ptr _string_node1;
+    SGPropertyNode_ptr _string_node2;
 
 };