Date/Time issue

Is Coranto not working properly for you? Here's where to ask for support help; for best results, follow these steps:
  • - Check your core/addon documentation for possible solutions
  • - Search these forums for similar problems that have already been solved
  • - If you're still stumped, check out THIS TOPIC, and post your question in this forum!!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

Date/Time issue

Postby web » Mon Jan 07, 2008 6:39 pm

I want to generate sitemap format file and using i style such code in W3C Datetimeformat

Code: Select all
<lastmod><Field: Year>-<Field: TwoDigitMonth>-<Field: TwoDigitDay>T<Field: TwoDigitHour>:<Field: Minute>:<Field: Second><Field: Time_Zone></lastmod>

I'm getting
Code: Select all
<lastmod>2008-01-20:42:00+0400</lastmod>


you can see, that there is no <Field: TwoDigitDay>

If I use a space befor T symbol, like
Code: Select all
<lastmod><Field: Year>-<Field: TwoDigitMonth>-<Field: TwoDigitDay> T<Field: TwoDigitHour>:<Field: Minute>:<Field: Second><Field: Time_Zone></lastmod>

Than it will show me in result

Code: Select all
<lastmod>2008-01-07 T20:42:00+0400</lastmod>

but I don't want any space before T symbol. Or I don't know if I can use a space before it.

what can I do?
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby Musicvid » Mon Jan 07, 2008 7:10 pm

Try escaping the T by putting a \ in front of it and see if that corrects the problem. Like >\T<

Two discussions of this issue can be found here:
http://www.coranto.org/forum/viewtopic.php?t=8531

and here:
http://coranto.org/forum/viewtopic.php?t=7191

I could also write you a quick fix to give an RFC8601 date/time in strftime, if you wish. Let me know.
Last edited by Musicvid on Mon Jan 07, 2008 7:23 pm, edited 1 time in total.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby web » Mon Jan 07, 2008 7:17 pm

it will be great if you can give quick solution
Code: Select all
<PerlCode>
$AtomTime = '<dc:date>' . $Year . '-' . $TwoDigitMonth . '-' . $TwoDigitDay . 'T' . $TwoDigitHour . ':' . $Minute . ':' . $Second . '+00:00</dc:date>';
</PerlCode>


think that is Psykosys's solution. is not?
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby Musicvid » Mon Jan 07, 2008 7:25 pm

Try the escape approach I edited in above while you were posting. I will give you the strftime quickie solution when I get home from work.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby web » Mon Jan 07, 2008 7:32 pm

i've got such result
Code: Select all
<lastmod>2008-01-07\T22:59:43+0400</lastmod>


but i solved problem with
Code: Select all
<PerlCode>
$AtomTime = '' . $Year . '-' . $TwoDigitMonth . '-' . $TwoDigitDay . 'T' . $TwoDigitHour . ':' . $Minute . ':' . $Second . '+00:00';
</PerlCode>


without
</dc:date>

anyway i'm very thankful
maybe your quick solution would be better or can help anybody else...
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby Musicvid » Mon Jan 07, 2008 7:56 pm

OK, here 'ya go:
Code: Select all
   
<PerlCode>
# Gets the current time in RFC8601 format
        use POSIX qw(strftime);
        my @nowDate = localtime(time);
        my $w3cDate = strftime("%Y-%m-%dT%T%z", @nowDate);
</PerlCode>


Use like this:
<lastmod><Field: w3cDate></lastmod>

This is untested, let me know if it works and I'll check the forum when I get home from work.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby web » Mon Jan 07, 2008 8:10 pm

yea it works

Code: Select all
<lastmod>2008-01-07T13:04:54-0700</lastmod>


one issue - Time Zone
what if I need +04:00?
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm

Postby Musicvid » Mon Jan 07, 2008 8:16 pm

If you need something other than the server time zone you had better go with your earlier solution since the TZ offset is settable within Coranto and can't be applied easily to strftime.

It is possible using Posix::locale but setting it up is a pain in the butt and is beyond the scope of most users' abilities/interests.

Thanks for your interest.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby web » Mon Jan 07, 2008 8:22 pm

Ok. thanks to you
User avatar
web
 
Posts: 176
Joined: Sun Nov 30, 2003 3:39 pm


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 3 guests

cron