export default {
    methods: {
        treatAsUTC: function (date) {
            var result = new Date(date);
            result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
            return result;
        },
        daysSinceToday: function (date) {
            var currentDate = new Date();
            var millisecondsPerDay = 24*60*60*1000;
            return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
        },
        getHRDate: function (dateString) {
            var date = new Date(dateString);
            var year = date.getFullYear();
            var month = date.toLocaleString('default', {month: 'short'});
            var day = date.getDate();
            var hour = date.getHours() % 12;
            var minute = date.getMinutes();
            var period = date.getHours() < 24 ? 'AM' : 'PM';

            return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
        },
        isZero: function(dateString) {
            return dateString === '0000-00-00 00:00:00'
        }
    }
}