Created
April 10, 2016 11:56
-
-
Save wmh/1fdb01dba58599d34dab64944bf05f8b to your computer and use it in GitHub Desktop.
Calculate time from central airport to nagoya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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