Passed
Push — master ( e97712...5fe6af )
by Yuichi
02:30
created

date.php ➔ elapse_days()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
use Carbon\Carbon;
3
4 5
if ( ! function_exists('strtodate') ) {
5
    function strtodate($date,$format='Y/m/d')
6
    {
7 2
        if ( $date ) {
8 1
            return date($format,strtotime($date));
9
        }
10 1
        return null;
11
    }
12 1
}
13
14 5
if ( ! function_exists('ym') ) {
15
    function ym($ym)
16
    {
17 2
        if ( $ym && $ym > 190001 ) {
18 1
            return (floor($ym/100)) . '年' . ( floor($ym%100)) . '月';
19
        }
20 1
        return null;
21
    }
22 1
}
23
24 5
if ( ! function_exists('elapse_days') ) {
25
    function elapse_days($timestamp)
26
    {
27 1
        return Carbon::createFromTimeStamp($timestamp)->diffInDays(Carbon::now(),false);
28
    }
29
}
30