Source

pebble / lib / src / datetime.c

Full commit
/** \file
 * Date/time calculations
 */

#include <stdint.h>
#include "pebble_os.h"
#include "pebble_th.h"


uint32_t
unix_epoch_time(
	const PblTm * const curr_time,
	const int gmt_offset
)
{
	long now = 0;

	now += (curr_time->tm_year-70)*31536000;
	now += ((curr_time->tm_year-69)/4)*86400;
	now -= ((curr_time->tm_year-1)/100)*86400;
	now += ((curr_time->tm_year+299)/400)*86400;
	now += curr_time->tm_yday*86400;
	now += curr_time->tm_hour*3600;
	now += curr_time->tm_min*60;
	now += curr_time->tm_sec;
	now -= gmt_offset;

	return now;
}