(value)
Converts CommCare dates and datetimes to OpenMRS datetimes.

    >>> to_omrs_datetime('2017-06-27')
    '2017-06-27T00:00:00.000+0000'
Converts CommCare dates and datetimes to OpenMRS datetimes.
Converts CommCare dates and datetimes to OpenMRS datetimes .
def to_omrs_datetime(value):
    """
    Converts CommCare dates and datetimes to OpenMRS datetimes.

    >>> to_omrs_datetime('2017-06-27')
    '2017-06-27T00:00:00.000+0000'

    """
    if isinstance(value, str):
        if not re.match(r'\d{4}-\d{2}-\d{2}', value):
            raise ValueError('"{}" is not recognised as a date or a datetime'.format(value))
        value = dateutil_parser.parse(value)
    if isinstance(value, (datetime.date, datetime.datetime)):
        micros = value.strftime('%f')[:3]  # Only 3 digits for OpenMRS
        tz = value.strftime('%z') or '+0000'  # If we don't know, lie
        return value.strftime('%Y-%m-%dT%H:%M:%S.{f}{z}'.format(f=micros, z=tz))
def to_omrs_datetime ( value ) : if isinstance ( value , str ) : if not re . match ( r'\d{4}-\d{2}-\d{2}' , value ) : raise ValueError ( '"{}" is not recognised as a date or a datetime' . format ( value ) ) value = dateutil_parser . parse ( value ) if isinstance ( value , ( datetime . date , datetime . datetime ) ) : micros = value . strftime ( '%f' ) [ : 3 ] # Only 3 digits for OpenMRS tz = value . strftime ( '%z' ) or '+0000' # If we don't know, lie return value . strftime ( '%Y-%m-%dT%H:%M:%S.{f}{z}' . format ( f = micros , z = tz ) )