Set DateTime Data from strings



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 20/08/2011 at 07:57, xxxxxxxx wrote:

    Trying to set DateTime from external file (exif)
    Any pointer how to format the DateTimeData() object?
    What I have are strings that need to go "into" the:
    mytimedata = DateTimeData()

    The code here prints a skyobject datetime, I'd like to go
    the other way using my strings as base.

    Cheers
    Lennart

      
    import c4d   
    from c4d import gui, DateTimeData   
      
    def main() :   
        sky    = doc.GetFirstObject()   
        skybc = sky.GetDataInstance()   
        skydtd = skybc.GetData(c4d.SKY_DATE_TIME)   
        print DateTimeData.GetDateTime(skydtd)   
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/08/2011 at 04:53, xxxxxxxx wrote:

    Hi, here is a sample code how to parse a string into a DateTimeData object.
    And here you get a list of the directives for the string parser (strptime) :
    http://docs.python.org/library/datetime.html#strftime-strptime-behavior

    import c4d
    import datetime
      
    from datetime import datetime
    from c4d import gui, DateTimeData
      
    def main() :
        sky    = doc.GetFirstObject()
        skybc  = sky.GetDataInstance()
      
        td=datetime.strptime('16.07.2011 03:37:12',"%d.%m.%Y %H:%M:%S")
        
        dtd=DateTimeData()
        #set the datetime.datetime object to the DateTimeData object
        dtd.SetDateTime(td)
      
        skybc.SetData(c4d.SKY_DATE_TIME,dtd)
      
        c4d.EventAdd()
      
    main()
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/08/2011 at 05:31, xxxxxxxx wrote:

    Great, many thanks.

    Cheers
    Lennart


Log in to reply