Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Pitfall in function.html_select_date.php - $day_value_format

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Preissnbua
Smarty Rookie


Joined: 31 Aug 2003
Posts: 5
Location: Nürnberg, Germany

PostPosted: Mon Sep 01, 2003 7:35 am    Post subject: Pitfall in function.html_select_date.php - $day_value_format Reply with quote

Hi there,
after having read the Announcement in the Bugs-Forum, I decided to post this "pitfall" here Wink

I wrote a little CMS using the function.html_select_date.php AND function.html_select_time.php in order to be able to write news which are only displayed within a certain date- and timerange, so that I can write a bunch of articles which will appear on the date and time stored in my database.

So today I wrote an article and wanted to have it online at 07:10 a.m.

In my CMS I selected
2003 09 01 07 10 00
with the help of the select dropdown boxes.

I saved it, but the article didn't appear.
Instead the html_select_date displayed something like
2003 09 17 10 00 00

After some checking I found out that - for whatever reason - the default value for the variable "day_value_format" in the function.html_select_date.php reads

Code:
$day_value_format="%d";


Neither Date_Month nor Date_Hour nor Date_Minute nor Date_Second uses "%d" - only Date_Day. Why is that?

So I changed the value to
Code:
$day_value_format="%02d";

and it worked as expected.

Maybe this is of help for someone...

Best,
Preissnbua

P.S.:
I am not working with a Unix timestamp in my database, but really need the four digits year and two digits (with the leading zeros) for everything else version of "my timestamp"...
Back to top
View user's profile Send private message
Enquest
Smarty Regular


Joined: 14 May 2003
Posts: 79

PostPosted: Wed Oct 29, 2003 11:09 am    Post subject: Reply with quote

I don't understand it.

I want in the day value box the following "mon 14"
This aint happening with $day_value_format="%a"

Further more I'm wondering what day_extra does. It doesn't seem to do much.

Thanxs for the any help...
_________________
-----------------------
Learning my self by trying to help others
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 29, 2003 11:43 am    Post subject: Reply with quote

Enquest: the day_format and day_value_format are format-strings for sprintf, not for strftime. you can just format the numbers from 1 to 31, but they don't know their month, year or day-of-week.

day_extra is appended to the select-tag for the day. like
{html_select_date day_extra='class="foo"'}
to obtain sth. like <select name="Date_Day" class="foo">

HTH
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Preissnbua
Smarty Rookie


Joined: 31 Aug 2003
Posts: 5
Location: Nürnberg, Germany

PostPosted: Wed Oct 29, 2003 11:49 am    Post subject: Reply with quote

Enquest wrote:
I don't understand it.

I want in the day value box the following "mon 14"
This aint happening with $day_value_format="%a"

Further more I'm wondering what day_extra does. It doesn't seem to do much.

Thanxs for the any help...

Hi there,
I didn't try it, but from what is written in the documentation it seems, that for the day_format one is only allowed to use the possibilities sprintf has to offer, whereas when it comes to month_format you can choose from the possibilities strftime has to offer, which is quite a difference.

Regarding day_extra:
I used all_extra to assign a css-class to the select boxes in order to have them nicely displayed. I assume that the same works with day_extra - so it actually "does much".

Cheers,
Preissnbua
Back to top
View user's profile Send private message
Preissnbua
Smarty Rookie


Joined: 31 Aug 2003
Posts: 5
Location: Nürnberg, Germany

PostPosted: Wed Oct 29, 2003 11:50 am    Post subject: Reply with quote

messju wrote:
Enquest: the day_format and day_value_format are format-strings for sprintf, not for strftime. you can just format the numbers from 1 to 31, but they don't know their month, year or day-of-week.

day_extra is appended to the select-tag for the day. like
{html_select_date day_extra='class="foo"'}
to obtain sth. like <select name="Date_Day" class="foo">

HTH
messju

damn - i was too slow... Sad
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP