Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bertrandom/berttimezonebundle
Readable Timezone Field Type for Symfony2
https://github.com/bertrandom/berttimezonebundle
Last synced: about 1 month ago
JSON representation
Readable Timezone Field Type for Symfony2
- Host: GitHub
- URL: https://github.com/bertrandom/berttimezonebundle
- Owner: bertrandom
- Created: 2011-08-10T23:21:52.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-08-11T03:14:25.000Z (over 12 years ago)
- Last Synced: 2023-04-17T14:00:28.512Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 671 KB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Readable Timezone Field Type for Symfony2
=========================================The stock Symfony2 timezone field type organizes all of the Olson Timezone Identifiers in PHP by Continent and displays them to the user. This dropdown is pretty bad from a UI perspective. This bundles provides an alternate dropdown that is similar to the one found when choosing a time zone on a Windows computer.
This is my first symfony2 bundle, feedback welcome!
Installation
------------Edit your
deps
file and add the following:```
[BertTimezoneBundle]
git=git://github.com/bertrandom/BertTimezoneBundle.git
target=/bundles/Bert/TimezoneBundle
```Run the vendors install script:
`
bin/vendors install
`This will pull down the latest version of this bundle from github. Alternatively you can just put the files in
/vendor/bundles/Bert/TimezoneBundle
Next, add the namespace to the end of the
registerNamespaces
bit inautoload.php
:
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',.
.
.'Bert' => __DIR__.'/../vendor/bundles',
));Add the bundle in
AppKernel.php
:
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),.
.
.new Bert\TimezoneBundle\BertTimezoneBundle(),
);That's it, the field type should be ready to use.
Usage
-----Simply use the field type
readabletimezone
in your form builder, e.g.:
$builder
->add('username')
->add('plainPassword', 'repeated', array('type' => 'password'))
->add('firstname')
->add('lastname')
->add('email', 'email')
->add('timezone', 'readabletimezone')
;Data
----The data is taken from the work of two blog posts on the subject of readable timezones:
[Presenting a list of Timezones to the user](http://www.aviblock.com/blog/2009/03/12/presenting-a-list-of-timezones-to-the-user/)
[Olson Time Zone Database to Standard Windows Time Zone v0.1](http://www.timdavis.com.au/data/olson-time-zone-database-to-standard-windows-time-zone-v01/)
I've made mirrors of these two posts and put them in
Resources/source/mirrors/
in case the blog posts go away.The timezone data itself can be found in
Resources/config/timezones.yml
Credits
-------Bertrand Fan (
[email protected]
)Timezone data provided by Avi Block and Tim Davis, see Data section for more details.