*ut datetime to mjd*

        If the date given has no time associated with it (e.g. ``20160426``), then the datetime assumed is ``20160426 00:00:00.0``.

        Precision should be respected. 

        **Key Arguments:**
            - ``utDatetime`` -- UT datetime. Can accept various formats e.g. ``201604261444``, ``20160426``, ``20160426144444.5452``, ``2016-04-26 14:44:44.234``, ``20160426 14h44m44.432s`` 

        **Return:**
            - ``mjd`` -- the MJD

        .. todo ::

            - replace getMJDFromSqlDate in all code

        **Usage:**

            .. code-block:: python 

                from astrocalc.times import conversions
                converter = conversions(
                    log=log
                )
                mjd = converter.ut_datetime_to_mjd(utDatetime="20160426t1446")
                print mjd

                # OUT: 57504.6153

                mjd = converter.ut_datetime_to_mjd(utDatetime="2016-04-26 14:44:44.234")
                print mjd

                # OUT: 57504.61440

def ut_datetime_to_mjd(
            self,
            utDatetime):
        """*ut datetime to mjd*

        If the date given has no time associated with it (e.g. ``20160426``), then the datetime assumed is ``20160426 00:00:00.0``.

        Precision should be respected. 

        **Key Arguments:**
            - ``utDatetime`` -- UT datetime. Can accept various formats e.g. ``201604261444``, ``20160426``, ``20160426144444.5452``, ``2016-04-26 14:44:44.234``, ``20160426 14h44m44.432s`` 

        **Return:**
            - ``mjd`` -- the MJD

        .. todo ::

            - replace getMJDFromSqlDate in all code

        **Usage:**

            .. code-block:: python 

                from astrocalc.times import conversions
                converter = conversions(
                    log=log
                )
                mjd = converter.ut_datetime_to_mjd(utDatetime="20160426t1446")
                print mjd

                # OUT: 57504.6153

                mjd = converter.ut_datetime_to_mjd(utDatetime="2016-04-26 14:44:44.234")
                print mjd

                # OUT: 57504.61440
        """
        self.log.info('starting the ``ut_datetime_to_mjd`` method')

        import time
        import re
        mjd = None

        # TRIM WHITESPACE FROM AROUND STRING
        utDatetime = utDatetime.strip()

        # DATETIME REGEX
        matchObject = re.match(
            r'^(?P<year>\d{4})\D?(?P<month>(0\d|1[0-2]))\D?(?P<day>([0-2]\d|3[0-1])(\.\d+)?)(\D?(?P<hours>([0-1]\d|2[0-3]))\D?(?P<minutes>\d{2})(\D?(?P<seconds>\d{2}(\.\d*?)?))?)?s?$', utDatetime)

        # RETURN ERROR IF REGEX NOT MATCHED
        if not matchObject:
            self.log.error(
                'UT Datetime is not in a recognised format. Input value was `%(utDatetime)s`' % locals())
            raise IOError(
                'UT Datetime is not in a recognised format. Input value was `%(utDatetime)s`' % locals())

        year = matchObject.group("year")
        month = matchObject.group("month")
        day = matchObject.group("day")
        hours = matchObject.group("hours")
        minutes = matchObject.group("minutes")
        seconds = matchObject.group("seconds")

        # CLEAN NUMBERS AND SET OUTPUT PRECISION
        if "." in day:
            fhours = (float(day) - int(float(day))) * 24
            hours = int(fhours)
            fminutes = (fhours - hours) * 60
            minutes = int(fminutes)
            seconds = fhours - minutes
            precision = len(repr(day).split(".")[-1])
        elif not hours:
            hours = "00"
            minutes = "00"
            seconds = "00"
            precision = 1
        elif not seconds:
            seconds = "00"
            # PRECISION TO NEAREST MIN i.e. 0.000694444 DAYS
            precision = 4
        else:
            if "." not in seconds:
                precision = 5
            else:
                decLen = len(seconds.split(".")[-1])
                precision = 5 + decLen

        # CONVERT VALUES TO FLOAT
        seconds = float(seconds)
        year = float(year)
        month = float(month)
        day = float(day)
        hours = float(hours)
        minutes = float(minutes)

        # DETERMINE EXTRA TIME (SMALLER THAN A SEC)
        extraTime = 0.
        if "." in repr(seconds):
            extraTime = float("." + repr(seconds).split(".")
                              [-1]) / (24. * 60. * 60.)

        # CONVERT TO UNIXTIME THEN MJD
        t = (int(year), int(month), int(day), int(hours),
             int(minutes), int(seconds), 0, 0, 0)
        unixtime = int(time.mktime(t))
        mjd = (unixtime / 86400.0 - 2400000.5 + 2440587.5) + extraTime

        mjd = "%0.*f" % (precision, mjd)

        self.log.info('completed the ``ut_datetime_to_mjd`` method')
        return mjd