#-*- coding: utf-8 -*-
"""
@file
@brief Various functions about conversions.
"""
import datetime

def str_to_datetime (dt, format = None):
    """
    convert a string into a datetime object, it can be:
        - 2013-05-24 18:49:46
        - 2013-05-24 18:49:46.568

    @param      dt      string
    @param      format  format for the conversion, the most complete one is:
                            @code
                            %Y-%m-%d %H:%M:%S.%f
                            @endcode
                        which you get by default
    @rtype              datetime
    """
    if "+" in dt : dt = dt.split("+")[0].strip()
    elif " -" in dt : dt = dt.split(" -")[0].strip()
    if format is None :
        if "." in dt :
            return datetime.datetime.strptime (dt, "%Y-%m-%d %H:%M:%S.%f")
        else :
            return datetime.datetime.strptime (dt, "%Y-%m-%d %H:%M:%S")
    else :
        return datetime.datetime.strptime (dt, format)

def timestamp_to_datetime(timestamp):
    """
    convert a time into a datetime
    @param      ctime       ctime object (time)
    @rtype                  datetime
    """
    return datetime.datetime.utcfromtimestamp(timestamp)
@@ -563,32 +563,156 @@
        datetime%0A
+    @return             datetime%0A    %0A    .. versionchanged:: 1.0%0A        accept more formats (no time, T instead of space)%0A
     %22%22%22%0A    if %22
@@ -825,24 +825,50 @@
 t is None :%0A
+        if %22 %22 in dt:%0A    
         if %22
@@ -878,16 +878,20 @@
 in dt :%0A
+    
         
@@ -961,24 +961,28 @@
 f%22)%0A        
+    
 else :%0A     
@@ -980,32 +980,36 @@
 e :%0A            
+  
+  
 return datetime.
@@ -1052,16 +1052,318 @@
 %25M:%25S%22)%0A
+        elif %22T%22 in dt:%0A            if %22.%22 in dt :%0A                return datetime.datetime.strptime (dt, %22%25Y-%25m-%25dT%25H:%25M:%25S.%25f%22)%0A            else :%0A                return datetime.datetime.strptime (dt, %22%25Y-%25m-%25dT%25H:%25M:%25S%22)%0A        else:%0A            return datetime.datetime.strptime (dt, %22%25Y-%25m-%25d%22)%0A
     else

improve str_to_datetime which converts a string into a date