// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.time');
goog.require('cljs.core');
/**
 * Converts a campaign time map to a long - a time in milliseconds.
 */
weathergen.time.campaign_time__GT_ms = (function weathergen$time$campaign_time__GT_ms(p__30449){
var map__30452 = p__30449;
var map__30452__$1 = ((((!((map__30452 == null)))?((((map__30452.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30452.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30452):map__30452);
var t = map__30452__$1;
var day = cljs.core.get.call(null,map__30452__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__30452__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__30452__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
var second = cljs.core.get.call(null,map__30452__$1,new cljs.core.Keyword(null,"second","second",-444702010));
var millisecond = cljs.core.get.call(null,map__30452__$1,new cljs.core.Keyword(null,"millisecond","millisecond",-540123566));
return ((((((((day * (24)) + hour) * (60)) + minute) * (60)) + second) * (1000)) + millisecond);
});
/**
 * Converts a time in milliseconds to a campaign time map.
 */
weathergen.time.ms__GT_campaign_time = (function weathergen$time$ms__GT_campaign_time(data){
var d = cljs.core.long$.call(null,((((data / (24)) / (60)) / (60)) / (1000)));
var h = cljs.core.long$.call(null,(((cljs.core.mod.call(null,data,((((24) * (60)) * (60)) * (1000))) / (60)) / (60)) / (1000)));
var m = cljs.core.long$.call(null,((cljs.core.mod.call(null,data,(((60) * (60)) * (1000))) / (60)) / (1000)));
var s = cljs.core.long$.call(null,(cljs.core.mod.call(null,data,((60) * (1000))) / (1000)));
var ms = cljs.core.mod.call(null,data,(1000));
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"day","day",-274800446),(d + (1)),new cljs.core.Keyword(null,"hour","hour",-555989214),h,new cljs.core.Keyword(null,"minute","minute",-642875969),m,new cljs.core.Keyword(null,"second","second",-444702010),s,new cljs.core.Keyword(null,"millisecond","millisecond",-540123566),ms], null);
});
/**
 * Converts a time in minutes to a campaign time map.
 */
weathergen.time.minutes__GT_campaign_time = (function weathergen$time$minutes__GT_campaign_time(min){
var d = (Math.floor(((min / (24)) / (60))) | (0));
var h = (Math.floor((cljs.core.mod.call(null,min,((24) * (60))) / (60))) | (0));
var m = (Math.floor(cljs.core.mod.call(null,min,(60))) | (0));
return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"day","day",-274800446),(d + (1)),new cljs.core.Keyword(null,"hour","hour",-555989214),h,new cljs.core.Keyword(null,"minute","minute",-642875969),m], null);
});
/**
 * Converts from Falcon time to a weather-space time coordinate.
 */
weathergen.time.campaign_time__GT_minutes = (function weathergen$time$campaign_time__GT_minutes(t){
var map__30456 = t;
var map__30456__$1 = ((((!((map__30456 == null)))?((((map__30456.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30456.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30456):map__30456);
var day = cljs.core.get.call(null,map__30456__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__30456__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__30456__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
return (((((day - (1)) * (24)) + hour) * (60)) + minute);
});
/**
 * Adds minutes to a Falcon time map.
 */
weathergen.time.add_minutes = (function weathergen$time$add_minutes(t,min){
return weathergen.time.minutes__GT_campaign_time.call(null,(weathergen.time.campaign_time__GT_minutes.call(null,t) + min));
});
/**
 * Returns a difference in hours, minutes, and seconds (in a map) between two campaign times
 */
weathergen.time.difference_hms = (function weathergen$time$difference_hms(t1,t2){
var map__30460 = weathergen.time.ms__GT_campaign_time.call(null,(weathergen.time.campaign_time__GT_ms.call(null,t2) - weathergen.time.campaign_time__GT_ms.call(null,t1)));
var map__30460__$1 = ((((!((map__30460 == null)))?((((map__30460.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30460.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30460):map__30460);
var t = map__30460__$1;
var day = cljs.core.get.call(null,map__30460__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__30460__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
return cljs.core.update.call(null,cljs.core.dissoc.call(null,t,new cljs.core.Keyword(null,"day","day",-274800446)),new cljs.core.Keyword(null,"hour","hour",-555989214),cljs.core._PLUS_,((24) * (day - (1))));
});
