'use strict';

angular.module('qusion.filters.date', [])
    .filter('qdate', [
        "$filter",
        function($filter) {
            var date = $filter('date');

            return function(text, format) {
                if (!text) return null;

                text = text.replace(/^((?:\d{4}-\d\d-\d\dT)?\d\d:\d\d(?::\d\d(?::\.\d+)?)?)$/, '$1Z');

                if (angular.isString(text))
                    text = new Date(text);

                return date(text, format);
            };
        }
    ]);