Guest User

get-local-times.sh - tzdata update test for RUS, UKR, BLR

a guest
Oct 15th, 2011
468
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. ################################################################################
  4. ##  Script name: get-local-times.sh
  5. ##  Script version: 1.0 (2011-10-15 22:00 UTC)
  6. ##  Description: Script gets local times in different locations (Moscow,
  7. ##  Kaliningrad, Kiev, Minsk) for each of 5 given UTC dates, using system's TZ
  8. ##  database, and compares the result with the correct values ​​of local dates.
  9. ##  Author: Roman Tik (ya.roman.tik {аt} yandex.ru)
  10. ################################################################################
  11.  
  12. # Testing dates in UTC
  13. D1UTC="2010-10-01 15:00 UTC"
  14. D2UTC="2010-11-01 15:00 UTC"
  15. D3UTC="2011-10-01 15:00 UTC"
  16. D4UTC="2011-11-01 15:00 UTC"
  17. D5UTC="2012-07-01 15:00 UTC"
  18.  
  19. # Correct values for local times in Europe/Moscow:
  20. D1MSKCORRECT="2010-10-01 19:00 MSD (UTC+04)"
  21. D2MSKCORRECT="2010-11-01 18:00 MSK (UTC+03)"
  22. D3MSKCORRECT="2011-10-01 19:00 MSK (UTC+04)"
  23. D4MSKCORRECT="2011-11-01 19:00 MSK (UTC+04)"
  24. D5MSKCORRECT="2012-07-01 19:00 MSK (UTC+04)"
  25.  
  26. # Correct values for local times in Europe/Kaliningrad:
  27. D1KLGCORRECT="2010-10-01 18:00 EEST (UTC+03)"
  28. D2KLGCORRECT="2010-11-01 17:00 EET (UTC+02)"
  29. D3KLGCORRECT="2011-10-01 18:00 FET (UTC+03)"
  30. D4KLGCORRECT="2011-11-01 18:00 FET (UTC+03)"
  31. D5KLGCORRECT="2012-07-01 18:00 FET (UTC+03)"
  32.  
  33. # Correct values for local times in Europe/Kiev:
  34. D1KIEVCORRECT="2010-10-01 18:00 EEST (UTC+03)"
  35. D2KIEVCORRECT="2010-11-01 17:00 EET (UTC+02)"
  36. D3KIEVCORRECT="2011-10-01 18:00 FET (UTC+03)"
  37. D4KIEVCORRECT="2011-11-01 18:00 FET (UTC+03)"
  38. D5KIEVCORRECT="2012-07-01 18:00 FET (UTC+03)"
  39.  
  40. # Correct values for local times in Europe/Minsk:
  41. D1MINSKCORRECT="2010-10-01 18:00 EEST (UTC+03)"
  42. D2MINSKCORRECT="2010-11-01 17:00 EET (UTC+02)"
  43. D3MINSKCORRECT="2011-10-01 18:00 FET (UTC+03)"
  44. D4MINSKCORRECT="2011-11-01 18:00 FET (UTC+03)"
  45. D5MINSKCORRECT="2012-07-01 18:00 FET (UTC+03)"
  46.  
  47. echo "Testing dates (UTC):"
  48. echo 1. $D1UTC
  49. echo 2. $D2UTC
  50. echo 3. $D3UTC
  51. echo 4. $D4UTC
  52. echo 5. $D5UTC
  53. echo
  54. echo "Script gets local times in different locations (Moscow, Kaliningrad, Kiev, Minsk) for each of 5 given UTC dates, using system's TZ database, and compares the result with the correct values ​​of local dates."
  55.  
  56. export TZ="Europe/Moscow"
  57. D1MSK=`date -d "$D1UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  58. D2MSK=`date -d "$D2UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  59. D3MSK=`date -d "$D3UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  60. D4MSK=`date -d "$D4UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  61. D5MSK=`date -d "$D5UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  62. export TZ="Europe/Kaliningrad"
  63. D1KLG=`date -d "$D1UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  64. D2KLG=`date -d "$D2UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  65. D3KLG=`date -d "$D3UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  66. D4KLG=`date -d "$D4UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  67. D5KLG=`date -d "$D5UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  68. export TZ="Europe/Kiev"
  69. D1KIEV=`date -d "$D1UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  70. D2KIEV=`date -d "$D2UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  71. D3KIEV=`date -d "$D3UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  72. D4KIEV=`date -d "$D4UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  73. D5KIEV=`date -d "$D5UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  74. export TZ="Europe/Minsk"
  75. D1MINSK=`date -d "$D1UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  76. D2MINSK=`date -d "$D2UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  77. D3MINSK=`date -d "$D3UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  78. D4MINSK=`date -d "$D4UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  79. D5MINSK=`date -d "$D5UTC" +%Y-%m-%d" "%H:%M" "%Z" (UTC"%:::z")"`
  80.  
  81. echo
  82. echo "Testing dates in Moscow (Russia):"
  83. echo -n 1. $D1MSK
  84. if [ "$D1MSK" = "$D1MSKCORRECT" ]; then echo " [OK]";
  85. else echo " [WRONG]"; echo "Correct local time:" $D1MSKCORRECT
  86. fi
  87. echo -n 2. $D2MSK
  88. if [ "$D2MSK" = "$D2MSKCORRECT" ]; then echo " [OK]";
  89. else echo " [WRONG]"; echo "Correct local time:" $D2MSKCORRECT
  90. fi
  91. echo -n 3. $D3MSK
  92. if [ "$D3MSK" = "$D3MSKCORRECT" ]; then echo " [OK]";
  93. else echo " [WRONG]"; echo "Correct local time:" $D3MSKCORRECT
  94. fi
  95. echo -n 4. $D4MSK
  96. if [ "$D4MSK" = "$D4MSKCORRECT" ]; then echo " [OK]";
  97. else echo " [WRONG]"; echo "Correct local time:" $D4MSKCORRECT
  98. fi
  99. echo -n 5. $D5MSK
  100. if [ "$D5MSK" = "$D5MSKCORRECT" ]; then echo " [OK]";
  101. else echo " [WRONG]"; echo "Correct local time:" $D5MSKCORRECT
  102. fi
  103.  
  104. echo
  105. echo "Testing dates in Kaliningrad (Russia):"
  106. echo -n 1. $D1KLG
  107. if [ "$D1KLG" = "$D1KLGCORRECT" ]; then echo " [OK]";
  108. else echo " [WRONG]"; echo "Correct local time:" $D1KLGCORRECT
  109. fi
  110. echo -n 2. $D2KLG
  111. if [ "$D2KLG" = "$D2KLGCORRECT" ]; then echo " [OK]";
  112. else echo " [WRONG]"; echo "Correct local time:" $D2KLGCORRECT
  113. fi
  114. echo -n 3. $D3KLG
  115. if [ "$D3KLG" = "$D3KLGCORRECT" ]; then echo " [OK]";
  116. else echo " [WRONG]"; echo "Correct local time:" $D3KLGCORRECT
  117. fi
  118. echo -n 4. $D4KLG
  119. if [ "$D4KLG" = "$D4KLGCORRECT" ]; then echo " [OK]";
  120. else echo " [WRONG]"; echo "Correct local time:" $D4KLGCORRECT
  121. fi
  122. echo -n 5. $D5KLG
  123. if [ "$D5KLG" = "$D5KLGCORRECT" ]; then echo " [OK]";
  124. else echo " [WRONG]"; echo "Correct local time:" $D5KLGCORRECT
  125. fi
  126.  
  127. echo
  128. echo "Testing dates in Kiev (Ukraine):"
  129. echo -n 1. $D1KIEV
  130. if [ "$D1KIEV" = "$D1KIEVCORRECT" ]; then echo " [OK]";
  131. else echo " [WRONG]"; echo "Correct local time:" $D1KIEVCORRECT
  132. fi
  133. echo -n 2. $D2KIEV
  134. if [ "$D2KIEV" = "$D2KIEVCORRECT" ]; then echo " [OK]";
  135. else echo " [WRONG]"; echo "Correct local time:" $D2KIEVCORRECT
  136. fi
  137. echo -n 3. $D3KIEV
  138. if [ "$D3KIEV" = "$D3KIEVCORRECT" ]; then echo " [OK]";
  139. else echo " [WRONG]"; echo "Correct local time:" $D3KIEVCORRECT
  140. fi
  141. echo -n 4. $D4KIEV
  142. if [ "$D4KIEV" = "$D4KIEVCORRECT" ]; then echo " [OK]";
  143. else echo " [WRONG]"; echo "Correct local time:" $D4KIEVCORRECT
  144. fi
  145. echo -n 5. $D5KIEV
  146. if [ "$D5KIEV" = "$D5KIEVCORRECT" ]; then echo " [OK]";
  147. else echo " [WRONG]"; echo "Correct local time:" $D5KIEVCORRECT
  148. fi
  149.  
  150. echo
  151. echo "Testing dates in Minsk (Belarus):"
  152. echo -n 1. $D1MINSK
  153. if [ "$D1MINSK" = "$D1MINSKCORRECT" ]; then echo " [OK]";
  154. else echo " [WRONG]"; echo "Correct local time:" $D1MINSKCORRECT
  155. fi
  156. echo -n 2. $D2MINSK
  157. if [ "$D2MINSK" = "$D2MINSKCORRECT" ]; then echo " [OK]";
  158. else echo " [WRONG]"; echo "Correct local time:" $D2MINSKCORRECT
  159. fi
  160. echo -n 3. $D3MINSK
  161. if [ "$D3MINSK" = "$D3MINSKCORRECT" ]; then echo " [OK]";
  162. else echo " [WRONG]"; echo "Correct local time:" $D3MINSKCORRECT
  163. fi
  164. echo -n 4. $D4MINSK
  165. if [ "$D4MINSK" = "$D4MINSKCORRECT" ]; then echo " [OK]";
  166. else echo " [WRONG]"; echo "Correct local time:" $D4MINSKCORRECT
  167. fi
  168. echo -n 5. $D5MINSK
  169. if [ "$D5MINSK" = "$D5MINSKCORRECT" ]; then echo " [OK]";
  170. else echo " [WRONG]"; echo "Correct local time:" $D5MINSKCORRECT
  171. fi
  172.  
  173.  
RAW Paste Data