/[gentoo]/xml/htdocs/proj/en/council/utctolocal.html
Gentoo

Contents of /xml/htdocs/proj/en/council/utctolocal.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Mon Aug 23 06:37:06 2010 UTC (4 years ago) by wired
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +11 -7 lines
File MIME type: text/html
utctolocal.html: updated getQueryParams function because it crashed latest chromium

1 <html>
2 <!--
3 this page converts UTC time to the user system's timezone
4 using javascript
5
6 v1.1
7 updated getQueryParams function because it crashed latest chromium!
8
9 v1.0
10
11 written by Alex Alexander <wired@gentoo.org>
12 !-->
13 <head>
14 <title>Convert UTC time to your timezone</title>
15
16 <style>
17 body {
18 margin: 0px;
19 padding: 0px;
20 background: black;
21 color: white;
22 font-family: Verdana;
23 font-size: 16px;
24 }
25 div {
26 padding: 5px;
27 }
28 div#localtime {
29 color: #00a5ee;
30 font-size: 30px;
31 }
32 .textbox {
33 background: #00a5ee;
34 border: 2px #00a5ee;
35 color: white;
36 font-size: 20px;
37 padding: 5px;
38 width: 80px;
39 text-align: center;
40 }
41 </style>
42
43 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
44
45 <script>
46 function getQueryParams(qs) {
47 var vars = [], hash;
48 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
49
50 for(var i = 0; i < hashes.length; i++) {
51 hash = hashes[i].split('=');
52 vars.push(hash[0]);
53 vars[hash[0]] = hash[1];
54 }
55
56 return vars;
57 }
58
59 function get_time_zone_offset( ) {
60 var current_date = new Date( );
61 var gmt_offset = current_date.getTimezoneOffset( ) / 60;
62 return gmt_offset;
63 }
64
65 function update_time() {
66 var t = $("#time").val();
67 var filter = /^[0-9]{1,2}$/;
68 var filter2 = /^[0-9]{2}:[0-9]{2}$/;
69 var filter3 = /^[0-9]{4}$/;
70 if ( ! filter.test(t) && ! filter2.test(t) && ! filter3.test(t) ) {
71 $("#localtime").html("You need to provide a valid time<br>in 'HH', 'HHMM' or 'HH:MM' format.");
72 return;
73 }
74 if ( filter3.test(t) ) {
75 t = [ t.substr(0,2), t.substr(2,4) ];
76 } else {
77 t = t.split(":");
78 }
79 if ( parseInt(t[0]) > 23 || parseInt(t[1]) > 59 ) {
80 $("#localtime").html("You need to provide a valid time<br>in 'HH', 'HHMM' or 'HH:MM' format.");
81 return;
82 }
83 t[0] = parseInt(t[0]) - parseInt(get_time_zone_offset());
84 if ( t[0] > 23 ) t[0] -= 24;
85 if ( t[0] < 0 ) t[0] += 24;
86
87 if ( t[1] == undefined )
88 t[1] = "00";
89 else if ( parseInt(t[1]) < 10 )
90 t[1] = "0"+parseInt(t[1]);
91
92 $("#localtime").html( t[0] + ":" + t[1] );
93 }
94
95 $().ready(function() {
96 var GET = getQueryParams();
97
98 var tz = get_time_zone_offset()*-1;
99 if ( tz > 0 ) tz = "+"+tz; else if ( tz == 0 ) tz = "";
100 $("#localtime_label").html($("#localtime_label").html() + " (UTC"+tz+")");
101 if ( GET['time'] != undefined ) {
102 $("#time").val(GET['time']);
103 update_time();
104 }
105 $("#time").keyup(function(){ update_time() });
106 });
107 </script>
108 </head>
109 <body>
110 <table cellspacing='0' cellpadding='0' align='center'>
111 <tr><td align='center'>
112
113 <div style='height: 5px; padding: 0;'></div>
114 <div>Enter time in UTC</div>
115 <div><input type='textbox' class='textbox' id='time' value='' /></div>
116 <div style='height: 5px'></div>
117 <div id='localtime_label'>Time converted to your system's timezone</div>
118 <div id='localtime'></div>
119 <div style='height: 15px'></div>
120 <div style='font-size: 12px'>Make sure your system time is correct or you'll get wrong results :p</div>
121 <div style='height: 5px'></div>
122 <div style='font-size: 12px; color: #00a5ee'>wired<br>@<br>gentoo.org</div>
123
124 </td></tr>
125 </table>
126 </body>
127 </html>

  ViewVC Help
Powered by ViewVC 1.1.20