[EXTENSION] Date picker (jQuery UI based)

Darn it, I thought 7-Zip could handle tar.gz properly. Yes, I know that extensions are supposed to go in the extensions directory. Kind of makes sense. Will extract via tar instead (I believe it's available for MSYS). Sorry, I thought that there was something wrong with this extension, it never crossed my mind that my extracting utility of choice might've messed up.

From my experience 7-Zip can handle .tar.gz files. But you might have to run it twice: It first unzips it, giving you a .tar file. Then you have to unpack that .tar file.

You can gunzip  the gz and then use this.

Quote

From my experience 7-Zip can handle .tar.gz files. But you might have to run it twice: It first unzips it, giving you a .tar file. Then you have to unpack that .tar file.

Yes, I'm pretty sure I've been able to earlier, but this time something odd happened; first a .tar shows up (normal), then when I extract it I get a dialog box saying "<something> seems to be an archive. Would you like to extract it?" which has never happened before.

Thanks, MetaYii. Turns out I already had tar. Four copies in fact (the more the better! >_<) : P

Version 1.6 - code cleanup

Congratulations!  It works great.

Just a small improvement suggestion:

It will be cool if the extension could take the default language from the application language selection and if it's not set use english as default.

If the default language doesn't exist, then you select english.

:D

Hi,

i've got a problem by setting the attribute name to the following:



array(


	'name'=>'filter[fromDay]',


	'value'=>$this->Filter['fromDay'],


	'theme'=>'cupertino',


	'language'=>'de',


	'mode'=>'focus',


	'fontSize'=>'1.5em',


	'dateFormat'=>'dd.mm.yy',


	'htmlOptions'=>array(


	'size'=>8


	)


)





but the Name will then converted to

filter_fromDay

As workaround i changed Line 583

 $html = CHtml::textField($this->htmlOptions['id'], $this->value, $this->htmlOptions);

to

 $html = CHtml::textField($this->name, $this->value, $this->htmlOptions);

But this will break on future updates…

Greetings from Germay

me23

@me23: changed in 1.7, can you try?

Quote

It will be cool if the extension could take the default language from the application language selection and if it's not set use english as default.

If the default language doesn't exist, then you select english.

Done in 1.8

Hi MetaYii,

thanks a lot, works like a charm now.

Greetings from Germany

me23

Hi, i'm new to Yii.

I've just got datepicker working, and i can set the fontSize in the view, but shouldn't it be possible to set it in the config file, so it would be set site wide?

Setting the fontSize:

in the view (works):

<?php $this->widget(‘application.extensions.juidatepicker.EDatePicker’,array(‘model’=>$weightform,‘attribute’=>‘date’,‘fontSize’=>‘0.8em’))?>

in the config (doesn't work - fontSize is ignored):

'juidatepicker'=>array(


			'class'=>'application.extensions.juidatepicker.EDatePicker',


			'fontSize'=>'0.8em'


		),

Regards,

Joel

Hi MetaYii,

i've got a new issue, by trying to set 'rangeSelect' in options, it seems that the options will be overwritten in Line 546:



if ($this->mode !== 'advanced') {


     $this->options = $this->makeOptions($baseUrl);


}


my current Workaround is following:



if ($this->mode !== 'advanced') {


         $this->options = array_merge($this->options, $this->makeOptions($baseUrl));


      }


and here is the corresponding line in view file:



<?php echo $this->widget('application.extensions.juidatepicker.EDatePicker', 


	array(


				'name'=>'Day',


    			'value'=>$this->Filter['fromDay'],


    			'language'=>'de',


    			'mode'=>'focus',


    			'dateFormat'=>'dd.mm.yy',


    			'fontSize'=>'1em',	


    			'options'=>array(	


    				'rangeSelect'=>'true',


    				'firstDay'=>'1',


    			),   


			));?>


I am using the newest Version 1.8.

May be you can take a look if you have the time…

Thank you!

Greetings from Germany

me23

Quote

I've just got datepicker working, and i can set the fontSize in the view, but shouldn't it be possible to set it in the config file, so it would be set site wide?

Hi, do you mean in the application configuration?

Quote

i've got a new issue, by trying to set 'rangeSelect' in options, it seems that the options will be overwritten in Line 546:


if ($this->mode !== 'advanced') {


     $this->options = $this->makeOptions($baseUrl);


}


Hi me23, sorry for the late answer, I didn’t see you post before. Actually the “advanced” mode was a bit redundant, so I opted to not to include it in 1.9. Better yet, the user’s options now take precedence over the “templates”. Take a look  8)

great job, I would like to suggest:

the TIMESTAMP mode is very useful if you are using db dates as integer to be abstracted from the date format of the daabases (mssql, mysql, etc…). I usually use to treat dates al bigint and put inside unix timestamps.

this datepicker has the option to use TIMESTAMP but the little problem is that in this mode in textbox appear unix seconds and this is not very nice to see.

I was thinking if there is a way to post the unix timestamp but to see a normal date in textbox.

Quote

this datepicker has the option to use TIMESTAMP but the little problem is that in this mode in textbox appear unix seconds and this is not very nice to see.

I was thinking if there is a way to post the unix timestamp but to see a normal date in textbox.

Hmm, let me check, because I don't think its possible to do this directly with the datepicker jquery widget, because the presentation in the textfield is the same as in the corresponding $_POST… that's the idea behind the format selector.

Anyway, you could use the time extension or PHP’s [tt]time[/tt]/[tt]mktime[/tt]/[tt]date[/tt] to convert the date from and to unix timestamps so you can use a nice format in your form and store them as timestamps in your database.

strtotime() is also a real helper here.

[quote=PHP manual]strtotime — Parse about any English textual datetime description into a Unix timestamp
[/quote]

Quote

strtotime() is also a real helper here.

You're right Mikl, I forgot that one.

yes, obviously i can use all of this php functions to do what i want with date but in my opinion should be good if you don't have to change nothing in the related controller to translate the $_POST values in something you will save in db.

anyway this is a solution.

Good news, about the advanced options, thanks. But where’s the download gone  ???. Can i find 1.9 somewhere else?