2017 © Pedro Peláez
 

symfony-bundle simple-date-bundle

A bundle for persian date in Symfony2

image

pouyasoft_ir/simple-date-bundle

A bundle for persian date in Symfony2

  • Tuesday, April 10, 2018
  • by msajadi824
  • Repository
  • 2 Watchers
  • 5 Stars
  • 291 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 9 Versions
  • 6 % Grown

The README.md

pouyasoft_ir/simple-date-bundle

A bundle for persian date in Symfony2, (*1)

Install

  • Install via Composer:
$ php composer require pouyasoft_ir/simple-date-bundle

Service

Service Name: pouya_soft.j_sdate_service, (*2)

Functions: * georgianToPersian:
Convert Georgian calendar (DateTime) To Persian (String).
Parameters:
* georgian: DateTime (default: null) * format: string (default: yyyy/MM/dd) View Intl Format * locale: string (default: fa) (e.g. fa, fa_IR, en, en_US, en_UK, ...) * calendar: string (default: persian) (e.g. gregorian, persian, islamic, ...) * latinizeDigit: bool (default: false) Convert Persian numbers to Latin Numbers. * persianToGeorgian:
Convert Persian calendar (String) To Georgian (DateTime).
Parameters:
* persian: string * format: string (default: yyyy/MM/dd) View Intl Format * locale: string (default: fa) (e.g. fa, fa_IR, en, en_US, en_UK, ...) * calendar: string (default: persian) (e.g. gregorian, persian, islamic, ...) * intlDateTimeInstance:
Return new Instance of IntlDateTime. Visit Blog of Ali Farhadi, (*3)

Sample:, (*4)

$shamsiString = $this->get('pouya_soft.j_sdate_service')->georgianToPersian(new \DateTime(), 'yyyy-MM-dd E');
//result: ۱۳۹۴-۱۱-۲۲ دوشنبه
$shamsiString = $this->get('pouya_soft.j_sdate_service')->persianToGeorgian('1394-11-22 دوشنبه', 'yyyy-MM-dd E');
//result: An instance of DateTime

Twig

Functions:
* gpDate:
Convert Georgian calendar (DateTime) To Persian (String).
Parameters:
* georgian: DateTime (default: null) * format: string (default: yyyy/MM/dd) View Intl Format * locale: string (default: fa) (e.g. fa, fa_IR, en, en_US, en_UK, ...) * calendar: string (default: persian) (e.g. gregorian, persian, islamic, ...) * latinizeDigit: bool (default: false) Convert Persian numbers to Latin Numbers. * pgDate:
Convert Persian calendar (String) To Georgian (DateTime).
Parameters:
* persian: string * format: string (default: yyyy/MM/dd) View Intl Format * locale: string (default: fa) (e.g. fa, fa_IR, en, en_US, en_UK, ...) * calendar: string (default: persian) (e.g. gregorian, persian, islamic, ...), (*5)

Sample:, (*6)

{{ date|gpDate }} <br>
{{ date|gpDate('yyyy-MM-dd E') }} <br>
{{ '1394/11/22'|gpDate }} <br>
{{ '1394-11-22 دوشنبه'|gpDate('yyyy-MM-dd E') }} <br>

Form

Type Name: PouyaSoftSDateType, (*7)

Parameters: * serverFormat: string (default: yyyy/MM/dd) View Intl Format
* clientFormat: string (default: yy/m/d) View DatePicker Format
* attr: array
You can add other DatePicker options to this param, but must change uppercase letters to lower and add dash before it. (see Samples), (*8)

note: Result of serverFormat and clientFormat, must be the same., (*9)

Sample:, (*10)

$builder
    ->add('date', PouyaSoftSDateType::class, [
        'serverFormat' => 'yyyy/MM/dd',
        'pickerOptions' => [
            'Format' => 'yyyy/MM/dd',
            'EnableTimePicker' => true,
            'GroupId' => 'group1',
            'FromDate' => true,
            'DisableBeforeToday' => true,
        ]
    ])
    ->add('date2', PouyaSoftSDateType::class, [
        'serverFormat' => 'yyyy-MM-dd E',
        'pickerOptions' => [
            'Format' => 'yyyy/MM/dd',
            'EnableTimePicker' => true,
            'GroupId' => 'group1',
            'ToDate' => true,
        ]
    ])

Date Picker

Requirements: * Bootstrap * Jquery, (*11)

Add this lines to head tag in base.html.twig file:, (*12)

<head>
    ...

    <link rel="stylesheet" href="{{ asset('bundles/pouyasoftsdate/MdBootstrapPersianDateTimePicker/jquery.md.bootstrap.datetimepicker.style.css') }}" />
    ...
</head>

Add this lines to end of body tag in base.html.twig file:, (*13)

<script type="text/javascript" src="{{ asset('bundles/pouyasoftsdate/MdBootstrapPersianDateTimePicker/jquery.md.bootstrap.datetimepicker.js') }}"></script>

Add this lines to config/packages/twig.yaml file:, (*14)

twig:
    form_themes:
        - '@PouyaSoftSDate/form/form_s_date.html.twig'

References: * Blog of Ali Farhadi * View Intl Format * Class Intldateformatter * MD.BootstrapPersianDateTimePicker, (*15)

The Versions

10/04 2018

dev-master

9999999-dev

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

10/04 2018

3.0.3

3.0.3.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

13/02 2018

3.0.2

3.0.2.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

12/02 2018

3.0.1

3.0.1.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

05/02 2018

3.0.0

3.0.0.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

11/12 2017

dev-version3

dev-version3

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

22/10 2017

2.0.3

2.0.3.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

28/02 2017

2.0.2

2.0.2.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-intl *

 

by mostafa sajadi

symfony persian jalali shamsi date bundle

04/03 2016

1.0.5

1.0.5.0

A bundle for persian date in Symfony2

  Sources   Download

MIT

The Requires

  • php >=5.2

 

by mostafa sajadi

symfony persian jalali shamsi date bundle