from datetime import datetime


def time_dif(initdate,enddate):
	"""
	To calculate de diference between two dates

	Author: Albenis Pérez Alarcón
	contact:apalarcon1991@gmail.com
	
	Parameters
	----------
	
	initdate : int
	init day in format YYYYMMDDHHmmss

	enddate : int
	end day in format YYYYMMDDHHmmss


	return the diference between enddate and initdate

	"""
	year_init=int(str(initdate)[0:4])
	mes_init=(int(str(initdate)[4:6]))
	day_init=(int(str(initdate)[6:8]))
	hour_init=(int(str(initdate)[8:10]))
	min_init=(int(str(initdate)[10:12]))
	seg_init=(int(str(initdate)[12:14]))
	
	year_end=int(str(enddate)[0:4])
	mes_end=(int(str(enddate)[4:6]))
	day_end=(int(str(enddate)[6:8]))
	hour_end=(int(str(enddate)[8:10]))
	min_end=(int(str(enddate)[10:12]))
	seg_end=(int(str(enddate)[12:14]))
	


	fecha1 = datetime(year_init, mes_init, day_init, hour_init, min_init, seg_init)
	fecha2 = datetime(year_end, mes_end, day_end, hour_end, min_end, seg_end)
	diferencia = fecha2 - fecha1

	return int((diferencia.total_seconds())/3600.)