[Zope] Splitting a datetime string into a date string and a time string

Tino Wildenhain tino@wildenhain.de
Thu, 17 May 2001 15:50:58 +0200


Hi Gitte,

obviously you have to have DateTime objects to manipulate
with them. If you convert them to strings beforehand you
are not able to use their methods later :)

If its a DateTime field in your database and not a
string field, the result must be a DateTime object
with all its methods, including strftime()
If not, you have to instantiate a DateTime object from
string like this: DateTime(date_time_as_string)

What are you doing with filenames in DTML anyway?
If you mean object IDs, you can construct it like this:

<dtml-let objID="_.DateTime(time_as_string).strftime('%Y%m%d')">
<dtml-var objID>
</dtml-let>

Omit this DateTime instantiation if you have a real datetime-object
from your database as it should be.

Regards
Tino Wildenhain


--On Donnerstag, 17. Mai 2001 15:02 +0200 Gitte Wange <gitte@mmmanager.org> 
wrote:

> On Thursday 17 May 2001 13:00, Tino Wildenhain wrote:
>> Hi Gitte,
>>
>> assuming you only want to display the date,
>> you could use the fmt-attribute of the dtml-var tag.
>> <dtml-var YourDate fmt="%Y %m %d">
>> <dtml-var YourDate fmt="%H:%M:%S">
>>
>> You can also use:
>>
>> <dtml-var "YourDate.strftime('%Y %m %d')"> respectively.
>
> Well when I try this, I get this error:
>
> Zope Error
>
> Zope has encountered an error while publishing this resource.
>
> Error Type: AttributeError
> Error Value: 'string' object has no attribute 'strftime'
>
> I also tried the other solution, but I got an error saying that the Y
> wasn't  a known format type.
>
> Anyone who can help me ?
>
> Regards
> Gitte Wange
>
>>
>> HTH
>> Tino Wildenhain
>> --On Donnerstag, 17. Mai 2001 11:29 +0200 Gitte Wange
>> <gitte@mmmanager.org>
>>
>> wrote:
>> > Hello,
>> >
>> > I have a small problem:
>> > In my database I have a datetime field.
>> > Now I need to split the content of that field into a date string and a
>> > time  string with these formats:
>> > date: YYYY/MM/DD
>> > time: HH:MM:SS
>> >
>> > How do I do that?
>> >
>> > Another thing:
>> > I also need to remove / : and spaces from the datetime string.
>> >
>> > How ?
>> >
>> > Regards
>> > --
>> > ************************
>> > Gitte Wange Jensen
>> >
>> > System Squid Developer
>> > MMManager Aps
>> > +45 29 72 79 72
>> >
>> > gitte@mmmanager.org
>> > ************************
>> >
>> > _______________________________________________
>> > Zope maillist  -  Zope@zope.org
>> > http://lists.zope.org/mailman/listinfo/zope
>> > **   No cross posts or HTML encoding!  **
>> > (Related lists -
>> >  http://lists.zope.org/mailman/listinfo/zope-announce
>> >  http://lists.zope.org/mailman/listinfo/zope-dev )