Completed
Push — master ( fd5b7f...3848cb )
by mehdi
02:50
created
src/Datium.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 {
36 36
 
37 37
     /**
38
-   * Store DateTime object
39
-   */
38
+     * Store DateTime object
39
+     */
40 40
     protected $date_time;
41 41
 
42 42
     protected static $static_date_time;
43 43
 
44 44
     /**
45
-   * Store config file statements
46
-   *
47
-   * @param array
48
-   */
45
+     * Store config file statements
46
+     *
47
+     * @param array
48
+     */
49 49
     protected $config;
50 50
 
51 51
     protected $date_interval_expression;
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
     protected $fromConfig;
64 64
 
65 65
     /**
66
-   * Return store day number
67
-   *
68
-   * @param integer
69
-   */
66
+     * Return store day number
67
+     *
68
+     * @param integer
69
+     */
70 70
     protected $day_of;
71 71
 
72 72
     protected $leap;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     protected $language;
93 93
 
94 94
     /**
95
-    * Datium class constructure
96
-    */
95
+     * Datium class constructure
96
+     */
97 97
     public function __construct()
98 98
     {
99 99
 
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     /**
152
-    * Return all datetime parts as an object
153
-    *
154
-    * @return object
155
-    */
152
+     * Return all datetime parts as an object
153
+     *
154
+     * @return object
155
+     */
156 156
     public function all()
157 157
     {
158 158
 
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
     }
176 176
 
177 177
     /**
178
-   * Get current datetime
179
-   *
180
-   * @since  Aug 17 2015
181
-   * @return object
182
-   */
178
+     * Get current datetime
179
+     *
180
+     * @since  Aug 17 2015
181
+     * @return object
182
+     */
183 183
     public static function now()
184 184
     {
185 185
 
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
     /**
193
-   * Create new date time
194
-   *
195
-   * @param integer $year   Year number
196
-   * @param integer $month  month number
197
-   * @param integer $day    day number
198
-   * @param integer $hour   hour number
199
-   * @param integer $minute minute number
200
-   * @param integer $second second number
201
-   *
202
-   * @return object
203
-   */
193
+     * Create new date time
194
+     *
195
+     * @param integer $year   Year number
196
+     * @param integer $month  month number
197
+     * @param integer $day    day number
198
+     * @param integer $hour   hour number
199
+     * @param integer $minute minute number
200
+     * @param integer $second second number
201
+     *
202
+     * @return object
203
+     */
204 204
     public static function create(
205 205
         $year = 2000,
206 206
         $month = 1,
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 
213 213
 
214 214
         /**
215
-       * When we want to set a Datetime object to Datium
216
-       */
215
+         * When we want to set a Datetime object to Datium
216
+         */
217 217
         if (func_num_args() === 1) {
218 218
             self::$static_date_time = func_get_arg(0);
219 219
 
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
     }
237 237
 
238 238
     /**
239
-    * Select The range between two date object
240
-    *
241
-    * @param object $date_start Start of the DateTime
242
-    * @param object $date_end   End of the DateTime
243
-    *
244
-    * @return object
245
-    */
239
+     * Select The range between two date object
240
+     *
241
+     * @param object $date_start Start of the DateTime
242
+     * @param object $date_end   End of the DateTime
243
+     *
244
+     * @return object
245
+     */
246 246
     public static function between($date_start, $date_end)
247 247
     {
248 248
 
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
     }
258 258
 
259 259
     /**
260
-   * Convert from current calendar, what type is current calendar?
261
-   *
262
-   * @param object $calendar Assigned calendar to start from
263
-   *
264
-   * @return $object
265
-   */
260
+     * Convert from current calendar, what type is current calendar?
261
+     *
262
+     * @param object $calendar Assigned calendar to start from
263
+     *
264
+     * @return $object
265
+     */
266 266
     public function from($calendar)
267 267
     {
268 268
 
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 
273 273
 
274 274
         /**
275
-     * We need this part for DayOf class
276
-     */
275
+         * We need this part for DayOf class
276
+         */
277 277
         $this->calendar_type = $calendar;
278 278
 
279 279
         $this->translate_to = $calendar;
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
     }
284 284
 
285 285
     /**
286
-    * Convert date to current Date
287
-    *
288
-    * @param object $calendar Assigned calendar to when calendar should start.
289
-    *
290
-    * @return object
291
-    */
286
+     * Convert date to current Date
287
+     *
288
+     * @param object $calendar Assigned calendar to when calendar should start.
289
+     *
290
+     * @return object
291
+     */
292 292
     public function to($calendar)
293 293
     {
294 294
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
         $this->date_time = $this->convert->to($calendar);
298 298
 
299 299
         /**
300
-     * We need this part for DayOf class
301
-     */
300
+         * We need this part for DayOf class
301
+         */
302 302
         $this->calendar_type = $calendar;
303 303
 
304 304
         $this->translate_to = $calendar;
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 
310 310
 
311 311
     /**
312
-   * Difference between two time
313
-   *
314
-   * @param DateTime $start Start of the date
315
-   * @param DateTime $end   End of the date
316
-   *
317
-   * @return object
318
-   */
312
+     * Difference between two time
313
+     *
314
+     * @param DateTime $start Start of the date
315
+     * @param DateTime $end   End of the date
316
+     *
317
+     * @return object
318
+     */
319 319
     public static function diff($start, $end)
320 320
     {
321 321
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
     }
325 325
 
326 326
     /**
327
-   * Add new date value to current date
328
-   *
329
-   * @param string $value How much date should be added to current date
330
-   *
331
-   * @return object
332
-   */
327
+     * Add new date value to current date
328
+     *
329
+     * @param string $value How much date should be added to current date
330
+     *
331
+     * @return object
332
+     */
333 333
     public function add($value)
334 334
     {
335 335
 
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
     }
355 355
 
356 356
     /**
357
-   * Sub date from current date
358
-   *
359
-   * @param string $value How much date should increase from current date
360
-   *
361
-   * @return obejct
362
-   */
357
+     * Sub date from current date
358
+     *
359
+     * @param string $value How much date should increase from current date
360
+     *
361
+     * @return obejct
362
+     */
363 363
     public function sub($value)
364 364
     {
365 365
 
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-   * Check if current year is leap or not
388
-   *
389
-   * @param string $type Name of the calendar to caculate leap year
390
-   *
391
-   * @return boolean
392
-   */
387
+     * Check if current year is leap or not
388
+     *
389
+     * @param string $type Name of the calendar to caculate leap year
390
+     *
391
+     * @return boolean
392
+     */
393 393
     public function leap()
394 394
     {
395 395
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
     }
401 401
 
402 402
     /**
403
-    * Caculate day of year or week
404
-    *
405
-    * @since Aug, 22 2015
406
-    *
407
-    * @return integer
408
-    */
403
+     * Caculate day of year or week
404
+     *
405
+     * @since Aug, 22 2015
406
+     *
407
+     * @return integer
408
+     */
409 409
     public function dayOf()
410 410
     {
411 411
 
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
     // }
434 434
 
435 435
     /**
436
-    * Return Datetime as a original object
437
-    *
438
-    * @since Oct 22, 2015
439
-    *
440
-    * @return object
441
-    */
436
+     * Return Datetime as a original object
437
+     *
438
+     * @since Oct 22, 2015
439
+     *
440
+     * @return object
441
+     */
442 442
     public function object()
443 443
     {
444 444
 
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
     }
448 448
 
449 449
     /**
450
-    * Translate current date string to selected language
451
-    *
452
-    * @param string $language language short name fa, en, ar ...
453
-    *
454
-    * @return object
455
-    */
450
+     * Translate current date string to selected language
451
+     *
452
+     * @param string $language language short name fa, en, ar ...
453
+     *
454
+     * @return object
455
+     */
456 456
     public function lang($language = 'fa')
457 457
     {
458 458
 
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
     }
470 470
 
471 471
     /**
472
-    * Return object as timestamp
473
-    *
474
-    * @return timestamp
475
-    */
472
+     * Return object as timestamp
473
+     *
474
+     * @return timestamp
475
+     */
476 476
     public function timestamp()
477 477
     {
478 478
 
@@ -481,14 +481,14 @@  discard block
 block discarded – undo
481 481
     }
482 482
 
483 483
     /**
484
-   * Return fainal result
485
-   *
486
-   * @param string $format Date format
487
-   *
488
-   * @since Aug 17 2015
489
-   *
490
-   * @return string
491
-   */
484
+     * Return fainal result
485
+     *
486
+     * @param string $format Date format
487
+     *
488
+     * @since Aug 17 2015
489
+     *
490
+     * @return string
491
+     */
492 492
     public function get($format = 'Y-m-d H:i:s')
493 493
     {
494 494
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
         if (is_null($this->toConfig)) {
506 506
             $this->toConfig = include 'CalendarSettings/' .
507
-                                       ucfirst($this->translate_to) . '.php';
507
+                                        ucfirst($this->translate_to) . '.php';
508 508
         }
509 509
 
510 510
         $string_date = $this->date_time->format($format);
Please login to merge, or discard this patch.
src/CalendarSettings/Hijri.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 return array (
7 7
 
8
- /************************************************************
8
+  /************************************************************
9 9
   *                        Convert to
10 10
   ************************************************************
11 11
   *
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
   *
14 14
   *\_________________________________________________________/
15 15
   */
16
-   'convert_to' => function ($date_time) {
16
+    'convert_to' => function ($date_time) {
17 17
 
18
-     $config = include 'Jalali.php';
18
+      $config = include 'Jalali.php';
19 19
 
20
-     $date_time = Datium::create($date_time)->to('jalali')->object();
20
+      $date_time = Datium::create($date_time)->to('jalali')->object();
21 21
 
22
-     $year = $date_time->format('Y');
22
+      $year = $date_time->format('Y');
23 23
 
24
-     $month = $date_time->format('n');
24
+      $month = $date_time->format('n');
25 25
 
26
-     $day = $date_time->format('d');
26
+      $day = $date_time->format('d');
27 27
 
28
-     $temp_day = 0 ;
28
+      $temp_day = 0 ;
29 29
 
30 30
     for ($i = 1; $i < $month; $i++) {
31 31
         $temp_day += $config[ 'month_days_number' ][ $i ];
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
         $temp_day++;
40 40
     }
41 41
 
42
-     $_year = ( ( ( ( ( $year - 1 ) * 365.2422 ) + $temp_day ) - 119) / 354.3670 ) + 1;
42
+      $_year = ( ( ( ( ( $year - 1 ) * 365.2422 ) + $temp_day ) - 119) / 354.3670 ) + 1;
43 43
 
44
-     $_year = explode('.', $_year);
44
+      $_year = explode('.', $_year);
45 45
 
46
-     $year = $_year[0];
46
+      $year = $_year[0];
47 47
 
48
-     $_month = $_year[1];
48
+      $_month = $_year[1];
49 49
 
50 50
       $var_temp = '0.0';
51 51
 
@@ -55,37 +55,37 @@  discard block
 block discarded – undo
55 55
 
56 56
       $var_temp .= '1';
57 57
 
58
-     $_month = $_month * $var_temp ;
58
+      $_month = $_month * $var_temp ;
59 59
 
60
-     $_month = ( $_month * 12 ) + 1;
60
+      $_month = ( $_month * 12 ) + 1;
61 61
 
62
-     $_month = explode('.', $_month);
62
+      $_month = explode('.', $_month);
63 63
 
64
-     $month = $_month[0];
64
+      $month = $_month[0];
65 65
 
66
-     $_day = $_month[1];
66
+      $_day = $_month[1];
67 67
 
68
-     $var_temp = '0.0';
68
+      $var_temp = '0.0';
69 69
 
70 70
     for ($i = strlen($_day); $i > 2; $i--) {
71 71
         $var_temp .= '0' ;
72 72
     }
73 73
 
74
-     $var_temp .= '1';
74
+      $var_temp .= '1';
75 75
 
76
-     $_day = $_day * $var_temp;
76
+      $_day = $_day * $var_temp;
77 77
 
78
-     $_day = ( $_day * 29.530 );
78
+      $_day = ( $_day * 29.530 );
79 79
 
80
-     $_day = explode('.', $_day);
80
+      $_day = explode('.', $_day);
81 81
 
82
-     $day = $_day[0];
82
+      $day = $_day[0];
83 83
 
84 84
     $date_time->setDate($year, $month, $day);
85 85
 
86 86
     return $date_time;
87 87
 
88
-   },
88
+    },
89 89
 
90 90
     /************************************************************
91 91
     *                        Convert From
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
         'Dhu al_Hijjah'
169 169
 
170
-     ),
170
+      ),
171 171
 
172 172
     /************************************************************
173 173
     *                        Days of Week
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
     *\_________________________________________________________/
180 180
     */
181 181
     'days_of_week' => array (
182
-         'al-Aḥad',
183
-         'al-Ithnayn',
184
-         'ath-Thulatha\'',
185
-         'al-Arbi\'a',
186
-         'al-Khamees',
187
-         'al-Jumu\'ah',
188
-         'as-Sabt',
182
+          'al-Aḥad',
183
+          'al-Ithnayn',
184
+          'ath-Thulatha\'',
185
+          'al-Arbi\'a',
186
+          'al-Khamees',
187
+          'al-Jumu\'ah',
188
+          'as-Sabt',
189 189
 
190 190
     ),
191 191
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 
202 202
 
203 203
     'month_days_number' => array(     1 => 30,
204
-                                     2 => 29,
205
-                                     3 => 30,
206
-                                     4 => 30,
207
-                                     5 => 29,
208
-                                     6 => 29,
209
-                                     7 => 30,
210
-                                     8 => 29,
211
-                                     9 => 30,
212
-                                     10 => 29,
213
-                                     11 => 30,
214
-                                     12 => 30 ),
204
+                                      2 => 29,
205
+                                      3 => 30,
206
+                                      4 => 30,
207
+                                      5 => 29,
208
+                                      6 => 29,
209
+                                      7 => 30,
210
+                                      8 => 29,
211
+                                      9 => 30,
212
+                                      10 => 29,
213
+                                      11 => 30,
214
+                                      12 => 30 ),
215 215
     /************************************************************
216 216
     *                      Day of year
217 217
     ************************************************************
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     *
221 221
     *\_________________________________________________________/
222 222
     */
223
-     'day_of_year' => function ($date_time) {
223
+      'day_of_year' => function ($date_time) {
224 224
 
225 225
         $result = null;
226 226
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 
241 241
         return $result;
242 242
 
243
-     },
243
+      },
244 244
 
245
-     /************************************************************
245
+      /************************************************************
246 246
       *                      Day of week
247 247
       ************************************************************
248 248
       *
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
       *  example : al-Aḥad = result is 1
251 251
       *\_________________________________________________________/
252 252
       */
253
-     'day_of_week' => function ($date_time) {
253
+      'day_of_week' => function ($date_time) {
254 254
 
255 255
         $configGhamari = include 'Hijri.php';
256 256
 
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
             }
267 267
         }
268 268
 
269
-     },
269
+      },
270 270
 
271
-     /************************************************************
271
+      /************************************************************
272 272
       *                       Leap year
273 273
       ************************************************************
274 274
       *
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
       *
277 277
       *\_________________________________________________________/
278 278
       */
279
-     'leap_year' => function ($year) {
279
+      'leap_year' => function ($year) {
280 280
         $result = $this->year % 30;
281 281
 
282 282
         if (( 2 == $result ) 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         ) {
294 294
             return $result;
295 295
         }
296
-     },
296
+      },
297 297
 
298 298
     /************************************************************
299 299
     *                        Weekend
Please login to merge, or discard this patch.
src/CalendarSettings/Jalali.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
         $temp_day += $config[ 'month_days_number' ][ $i ];
46 46
     }
47 47
 
48
-         $temp_day += $day;
48
+          $temp_day += $day;
49 49
 
50
-         $leap = new Leap($year);
50
+          $leap = new Leap($year);
51 51
 
52 52
     if ($leap->get() && $month > 2) {
53 53
         $temp_day++;
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
         }
102 102
     }
103 103
 
104
-         $date_time->setDate($year, $month, $day);
104
+          $date_time->setDate($year, $month, $day);
105 105
 
106
-         return $date_time;
106
+          return $date_time;
107 107
 
108 108
   },
109 109
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
       $date_time->setDate($gregorian_year, $gregorian_month, $gregorian_day);
169 169
 
170 170
 
171
-     return $date_time;
171
+      return $date_time;
172 172
 
173 173
   },
174 174
 
@@ -231,30 +231,30 @@  discard block
 block discarded – undo
231 231
 
232 232
   'days_of_week' => array (
233 233
 
234
-     'Yekshanbe',
235
-     'Doshanbe',
236
-     'Seshanbe',
237
-     'Chaharshanbe',
238
-     'Panjshanbe',
239
-     'Jome',
240
-     'Shanbe',
234
+      'Yekshanbe',
235
+      'Doshanbe',
236
+      'Seshanbe',
237
+      'Chaharshanbe',
238
+      'Panjshanbe',
239
+      'Jome',
240
+      'Shanbe',
241 241
 
242 242
   ),
243 243
 
244 244
   'start_day_of_week' => 'Shanbe',
245 245
 
246 246
   'month_days_number' => array(      1 => 31,
247
-                                     2 => 31,
248
-                                     3 => 31,
249
-                                     4 => 31,
250
-                                     5 => 31,
251
-                                     6 => 31,
252
-                                     7 => 30,
253
-                                     8 => 30,
254
-                                     9 => 30,
255
-                                     10 => 30,
256
-                                     11 => 30,
257
-                                     12 => 29 ),
247
+                                      2 => 31,
248
+                                      3 => 31,
249
+                                      4 => 31,
250
+                                      5 => 31,
251
+                                      6 => 31,
252
+                                      7 => 30,
253
+                                      8 => 30,
254
+                                      9 => 30,
255
+                                      10 => 30,
256
+                                      11 => 30,
257
+                                      12 => 29 ),
258 258
 
259 259
   /************************************************************
260 260
   *                      Day of year
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
    */
325 325
   'leap_year' => function ( $year ) {
326 326
 
327
-     $a = 0.025;
327
+      $a = 0.025;
328 328
 
329
-     $b = 266;
329
+      $b = 266;
330 330
 
331 331
     if ($year > 0) {
332 332
         $leapDays0 = (($year + 38) % 2820)*0.24219 + $a;  // 0.24219 ~ extra days of one year
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
         return false;
339 339
     }
340 340
 
341
-     $frac0 = intval(($leapDays0 - intval($leapDays0))*1000);
342
-     $frac1 = intval(($leapDays1 - intval($leapDays1))*1000);
341
+      $frac0 = intval(($leapDays0 - intval($leapDays0))*1000);
342
+      $frac1 = intval(($leapDays1 - intval($leapDays1))*1000);
343 343
 
344 344
     if ($frac0 <= $b && $frac1 > $b) {
345 345
         return true; 
@@ -360,4 +360,4 @@  discard block
 block discarded – undo
360 360
    */
361 361
   'weekend' => array( 'friday' )
362 362
 
363
- );
363
+  );
Please login to merge, or discard this patch.