[DRE-commits] [SCM] Tracking the Debian/Ruby wheezy transition branch, master, updated. a83d4d102753de4c9aecc3726961360aa1bbfc64
Antonio Terceiro
terceiro at softwarelivre.org
Wed Apr 6 19:37:06 UTC 2011
The following commit has been merged in the master branch:
commit a83d4d102753de4c9aecc3726961360aa1bbfc64
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date: Wed Apr 6 12:36:17 2011 -0700
Proper date handling
diff --git a/progressbar.js b/progressbar.js
index 8c155e7..041971d 100644
--- a/progressbar.js
+++ b/progressbar.js
@@ -1,31 +1,30 @@
+function to_date_string(date) {
+ return date.getFullYear() + "/" + date.getMonth() + "/" + date.getDate();
+}
+
+function to_proper_date(date_as_number) {
+ var year = Math.floor(date_as_number / 10000);
+ var month = Math.floor(date_as_number % 10000 / 100);
+ var day = Math.floor(date_as_number % 100);
+ return new Date(year, month - 1, day);
+}
$(function() {
$.getJSON('data.json', function(input) {
var pending = [];
var done = [];
- var initial_date = Infinity;
- var final_date = 0;
+ var initial_date = null;
+ var final_date = null;
$.each(input, function(index, point) {
- pending.push([point.date, point.pending]);
- done.push([point.date, point.done]);
- if (point.date < initial_date) { initial_date = point.date; }
- if (point.date > final_date) { final_date = point.date; }
+ var date = to_proper_date(point.date);
+ pending.push([date.getTime(), point.pending]);
+ done.push([date.getTime(), point.done]);
+ if (initial_date == null || date < initial_date) { initial_date = date; }
+ if (final_date == null || date > final_date) { final_date = date; }
});
- function to_date_string(date_as_number) {
- var proper_date = to_proper_date(date_as_number)
- return proper_date.getFullYear() + "/" + proper_date.getMonth() + "/" + proper_date.getDate();
- }
-
- function to_proper_date(date_as_number) {
- var year = Math.floor(date_as_number / 10000);
- var month = Math.floor(date_as_number % 10000 / 100);
- var day = Math.floor(date_as_number % 100);
- return new Date(year, month, day);
- }
-
$.plot(
$('#progress'),
[
@@ -36,8 +35,8 @@ $(function() {
series: { points: { show: true }, lines: { show: true } },
grid: { hoverable: true },
xaxis: {
- min: initial_date,
- max: final_date + 1, // always leave some empty space in the chart
+ min: initial_date.getTime(),
+ max: final_date.getTime() + 1000*60*60*24, // always leave some empty space in the chart, eqivalente to 1 day
ticks: [[initial_date, to_date_string(initial_date)], [final_date, to_date_string(final_date)]]
}
}
--
Tracking the Debian/Ruby wheezy transition
More information about the Pkg-ruby-extras-commits
mailing list