public static function parseDate($string, $direction = null, $equal_to = false)
    {
        $parts = array(
            'start' => null,
            'end' => null
        );

        // Year
        if (preg_match('/^\d{1,4}$/', $string, $matches)) {
            $year = current($matches);

            $parts['start'] = "$year-01-01 00:00:00";
            $parts['end'] = "$year-12-31 23:59:59";

            $parts = self::isEqualTo($parts, $direction, $equal_to);

            // Year/Month/Day/Time
        } elseif (preg_match('/^\d{1,4}[-\/]\d{1,2}[-\/]\d{1,2}\s\d{1,2}:\d{2}/', $string, $matches)) {
            // Handles the case of `to` filters
            if ($equal_to || is_null($direction)) {
                $parts['start'] = $parts['end'] = DateTimeObj::get('Y-m-d H:i:s', $string);
            } else {
                $parts['start'] = DateTimeObj::get('Y-m-d H:i:s', $string . ' - 1 second');
                $parts['end'] = DateTimeObj::get('Y-m-d H:i:s', $string . ' + 1 second');
            }

            // Year/Month/Day
        } elseif (preg_match('/^\d{1,4}[-\/]\d{1,2}[-\/]\d{1,2}$/', $string, $matches)) {
            $year_month_day = current($matches);

            $parts['start'] = "$year_month_day 00:00:00";
            $parts['end'] = "$year_month_day 23:59:59";

            $parts = self::isEqualTo($parts, $direction, $equal_to);

            // Year/Month
        } elseif (preg_match('/^\d{1,4}[-\/]\d{1,2}$/', $string, $matches)) {
            $year_month = current($matches);

            $parts['start'] = "$year_month-01 00:00:00";
            $parts['end'] = DateTimeObj::get('Y-m-t', $parts['start']) . " 23:59:59";

            $parts = self::isEqualTo($parts, $direction, $equal_to);

            // Relative date, aka '+ 3 weeks'
        } else {
            // Handles the case of `to` filters

            if ($equal_to || is_null($direction)) {
                $parts['start'] = $parts['end'] = DateTimeObj::get('Y-m-d H:i:s', $string);
            } else {
                $parts['start'] = DateTimeObj::get('Y-m-d H:i:s', $string . ' - 1 second');
                $parts['end'] = DateTimeObj::get('Y-m-d H:i:s', $string . ' + 1 second');
            }
        }

        return $parts;
    }