add time_dilation function to javascript function