| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace OrderCountingRecordService;
- use App\Services\CacheService;
- use App\Services\OrderCountingRecordService;
- use Carbon\Carbon;
- use DateInterval;
- use DatePeriod;
- use DateTime;
- use Tests\TestCase;
- class DateTestTest extends TestCase
- {
- /** @var OrderCountingRecordService $orderCountingRecordService */
- public $orderCountingRecordService;
- public function setUp(): void
- {
- parent::setUp();
- $this->orderCountingRecordService = app(OrderCountingRecordService::class);
- }
- /**
- * @test
- */
- public function carbon_date_equals()
- {
- $this->assertTrue('2020-11-25' == Carbon::now()->format('Y-m-d'));
- $this->assertTrue('2020-48' == Carbon::now()->year . '-' . Carbon::now()->week);
- $this->assertTrue('2020-11' == Carbon::now()->year . '-' . Carbon::now()->month);
- }
- /**
- * @test
- */
- public function compare_date()
- {
- $dateStr = '2020-12-30';
- $end = Carbon::parse($dateStr)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $dateStr;
- dd($end);
- }
- /**
- * @test
- */
- public function for_date()
- {
- $start = Carbon::now()->subMonth()->toDateString();
- $end = Carbon::now()->toDateString();
- $unit = '月';
- dump($start, $end, $unit);
- $dateArray =$this->orderCountingRecordService->periodDateToArray($start, $end, $unit);
- dd($dateArray);
- }
- }
|