-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packaged for laravel 5.* #5
base: master
Are you sure you want to change the base?
Changes from all commits
5652136
bd34d53
6ac3b36
b952d2f
7b7014a
cabf9e0
6170c2e
7e8fe7c
f08389a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Changelog | ||
|
||
All Notable changes to `laravel-jdate` will be documented in this file. | ||
|
||
### Added | ||
- packaged for laravel 5.* | ||
- falaki month names | ||
- config file (jdate.php) for month names (jalali\falaki) | ||
|
||
### Deprecated | ||
- Nothing | ||
|
||
### Fixed | ||
- README updated for installing package on laravel 5.* | ||
|
||
### Removed | ||
- Nothing | ||
|
||
### Security | ||
- Nothing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2016 :author_name <:author_email> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "sallar/laravel-jdate", | ||
"type": "library", | ||
"description": "This package helps developers to easily work with Jalali (Shamsi or Iranian) dates in Laravel applications", | ||
"keywords": [ | ||
"sallar", | ||
"laravel-jdate" | ||
], | ||
"homepage": "https://github.com/sallar/laravel-jdate", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "sallar", | ||
"email": "[email protected]", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my correct email is |
||
"homepage": "https://sallar.me", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"illuminate/support": "~5.1", | ||
"php" : "~5.5|~7.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "4.*", | ||
"scrutinizer/ocular": "~1.1", | ||
"squizlabs/php_codesniffer": "~2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Sallar\\jDate\\": "src" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit" | ||
}, | ||
"minimum-stability": "dev" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
return [ | ||
// jalali of falaki | ||
'type' => 'jalali' //default is jalali | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Sallar\jDate; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class jDateServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Perform post-registration booting of services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->publishes([ | ||
__DIR__.'/config/config.php' => config_path('jdate.php'), | ||
]); | ||
} | ||
|
||
/** | ||
* Register any package services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?php | ||
namespace Sallar\jDate; | ||
use \DateTime; | ||
use \DateTimeZone; | ||
/** | ||
* Jalali DateTime Class, supports years higher than 2038 | ||
* by: Sallar Kaboli | ||
|
@@ -437,8 +440,8 @@ private static function getDayNames($day, $shorten = false, $len = 1, $numeric = | |
|
||
private static function getMonthNames($month, $shorten = false, $len = 3) | ||
{ | ||
$ret = ''; | ||
switch ( $month ) { | ||
$ret = self::getMonth($month,'falaki'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make changes to this file, please send a pull request to the original project here: https://github.com/sallar/jDateTime |
||
/*switch ( $month ) { | ||
case '1': $ret = 'فروردین'; break; | ||
case '2': $ret = 'اردیبهشت'; break; | ||
case '3': $ret = 'خرداد'; break; | ||
|
@@ -451,7 +454,9 @@ private static function getMonthNames($month, $shorten = false, $len = 3) | |
case '10': $ret = 'دی'; break; | ||
case '11': $ret = 'بهمن'; break; | ||
case '12': $ret = 'اسفند'; break; | ||
} | ||
}*/ | ||
|
||
|
||
return ($shorten) ? mb_substr($ret, 0, $len, 'UTF-8') : $ret; | ||
} | ||
|
||
|
@@ -571,4 +576,54 @@ public static function toGregorian($j_y, $j_m, $j_d) | |
|
||
} | ||
|
||
/** | ||
* @author Morteza Rjabi | ||
* | ||
* get the specifid moonth | ||
* @param int $num month number 1-12 | ||
* @param string $type jalali or falaki | ||
* @return string month name | ||
*/ | ||
private static function getMonth($num ,$type= 'jalali') | ||
{ | ||
|
||
$jalali = [ '1'=> 'فروردین', | ||
'2'=> 'اردیبهشت', | ||
'3'=> 'خرداد', | ||
'4'=> 'تیر', | ||
'5'=> 'امرداد', | ||
'6'=> 'شهریور', | ||
'7'=> 'مهر', | ||
'8'=> 'آبان', | ||
'9'=> 'آذر', | ||
'10'=> 'دی', | ||
'11'=> 'بهمن', | ||
'12'=> 'اسفند']; | ||
|
||
$falaki = [ '1'=> 'حمل', | ||
'2'=> 'ثور', | ||
'3'=> 'جوزا', | ||
'4'=> 'سرطان', | ||
'5'=> 'اسد', | ||
'6'=> 'سنبله', | ||
'7'=> 'میزان', | ||
'8'=> 'عقرب', | ||
'9'=> 'قوس', | ||
'10'=> 'جدی', | ||
'11'=> 'دلو', | ||
'12'=> 'حوت']; | ||
|
||
if($num < 1 or $num > 12) | ||
return ''; | ||
|
||
|
||
if(config('jdate.type', $type) == 'jalali') //use $type if config does not exists. | ||
return $jalali[$num]; | ||
|
||
if(config('jdate.type', $type) == 'falaki') //use $type if config does not exists. | ||
return $falaki[$num]; | ||
|
||
return '';//if $type not mach jalali or falaki | ||
} | ||
|
||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to correct information?