Skip to content

Instantly share code, notes, and snippets.

@wmh
Created April 10, 2016 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmh/1fdb01dba58599d34dab64944bf05f8b to your computer and use it in GitHub Desktop.
Save wmh/1fdb01dba58599d34dab64944bf05f8b to your computer and use it in GitHub Desktop.
Calculate time from central airport to nagoya
// http://www.meitetsu.co.jp/cht/timetable/centrair/timetable/access_e05_02.html
$('table[bordercolor=lightgrey] tr').each(function () {
var $this = $(this),
$departCell = $this.find('td:nth-child(2)'),
$arriveCell = $this.find('td:nth-child(5)'),
departTime = $departCell.text(),
arriveTime = $arriveCell.text();
if (departTime.indexOf(':') == -1 || arriveTime.indexOf(':') == -1) {
return;
}
var departH = parseInt(departTime.split(':')[0], 10),
departM = parseInt(departTime.split(':')[1], 10),
arriveH = parseInt(arriveTime.split(':')[0], 10),
arriveM = parseInt(arriveTime.split(':')[1], 10),
hourDiff = arriveH - departH,
timeDiff = hourDiff * 60 + arriveM - departM;
$arriveCell.find('b').text($arriveCell.text() + ' ('+ timeDiff +')');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment