-
Notifications
You must be signed in to change notification settings - Fork 13
/
humandate.min.js
1 lines (1 loc) · 2.01 KB
/
humandate.min.js
1
!function(){var e={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsAbbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],toUTC:function(e){var t=e?new Date(e):new Date;return t=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())},monthName:function(t,n){var r,o;return"number"==typeof t?r=t:(o=new Date(t),r=o.getMonth()+1),n?e.monthsAbbreviated[r-1]:e.months[r-1]},relativeTime:function(e,t){function n(e,n){m&&(m=t.allUnits,h.push(e+" "+n+(e>1?"s":"")))}var r,o,a,u,s,i,f,m,h=[];return"number"==typeof e?r=e:(s=new Date(e),u=s.getTime(),i=(new Date).getTime(),r=(i-u)/1e3*-1),t||(t={}),t.futureSuffix||(t.futureSuffix="from now"),t.pastSuffix||(t.pastSuffix="ago"),t.presentText||(t.presentText="now"),t.returnObject||(t.returnObject=!1),f=r<0,r=Math.abs(r),o={seconds:Math.floor(r%31536e3%86400%3600%60),minutes:Math.floor(r%31536e3%86400%3600/60),hours:Math.floor(r%31536e3%86400/3600),days:Math.floor(r%31536e3/86400),years:Math.floor(r/31536e3),past:f},t.returnObject?o:0===r?t.presentText:(a=o.past?t.pastSuffix:t.futureSuffix,m=!0,o.years&&n(o.years,"year"),o.days&&n(o.days,"day"),o.hours&&n(o.hours,"hour"),o.minutes&&n(o.minutes,"minute"),o.seconds&&n(o.seconds,"second"),h.join(", ")+" "+a)},prettyPrint:function(e,t){var n,r,o,a,u,s,i,f,m,h;return e?"number"==typeof e&&(e=(new Date).setSeconds(e)):e=new Date,t||(t={}),t.showTime||(t.showTime=!1),t.monthAbbreviated||(t.monthAbbreviated=!1),n=new Date(e),o=n.getDate(),a=o>3&&o<21?o+"th":o%10===1?o+"st":o%10===2?o+"nd":o%10===3?o+"rd":o+"th",u=n.getFullYear(),s=this.monthName(n.getMonth()+1,t.monthAbbreviated),r=s+" "+a+", "+u,f=n.getHours(),m=n.getMinutes(),h=f>=12?"pm":"am",f=f%12?f%12:12,m=m<10?"0"+m:m,i=f+":"+m+" "+h,t.showTime?r+" at "+i:r}};if("undefined"!=typeof module&&module.exports)module.exports=e;else{if("function"==typeof define&&define.amd)return define([],function(){return e});this.humandate=e}}();