// 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__28971){
var map__28974 = p__28971;
var map__28974__$1 = ((((!((map__28974 == null)))?((((map__28974.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28974.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28974):map__28974);
var t = map__28974__$1;
var day = cljs.core.get.call(null,map__28974__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__28974__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__28974__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
var second = cljs.core.get.call(null,map__28974__$1,new cljs.core.Keyword(null,"second","second",-444702010));
var millisecond = cljs.core.get.call(null,map__28974__$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__28978 = t;
var map__28978__$1 = ((((!((map__28978 == null)))?((((map__28978.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28978.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28978):map__28978);
var day = cljs.core.get.call(null,map__28978__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__28978__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__28978__$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__28982 = 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__28982__$1 = ((((!((map__28982 == null)))?((((map__28982.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28982.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28982):map__28982);
var t = map__28982__$1;
var day = cljs.core.get.call(null,map__28982__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__28982__$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))));
});
