private function parseDate() { $f = pathinfo($this->filename, PATHINFO_FILENAME); $m = substr($f, 2, 2); $d = substr($f, 4, 2); $y = '20' . substr($f, 6, 2); if (is_iso_date($y . '-' . $m . '-' . $d)) { return Carbon::parse($y . '-' . $m . '-' . $d); } else { return null; } }
private function backupParseDate($filename) { $f = pathinfo($filename, PATHINFO_FILENAME); $m = substr($f, 2, 2); $d = substr($f, 4, 2); $y = '20' . substr($f, 6, 2); if (is_iso_date($y . '-' . $m . '-' . $d)) { return carbonCheckorNow($y . '-' . $m . '-' . $d); } else { return false; } }
private function parseDate() { $f = pathinfo($this->filename, PATHINFO_FILENAME); $m = substr($f, 2, 2); $d = substr($f, 4, 2); $y = '20' . substr($f, 6, 2); if (is_iso_date($y . '-' . $m . '-' . $d)) { //return Carbon::parse($y.'-'.$m.'-'.$d.' '.$this->uploaddate->format('H:i:s')); return Carbon::parse($y . '-' . $m . '-' . $d . ' 00:00:00'); } else { return null; } }
/** * Execute the console command. * * @return mixed */ public function handle() { $branch = is_null($this->option('branch')) ? $this->ask('Enter branch code') : $this->option('branch'); $from = is_null($this->option('from')) ? $this->ask('Enter year-month start [YYYY-MM]') : $this->option('from'); $to = is_null($this->option('to')) ? $this->ask('Enter year-month end [YYYY-MM]') : $this->option('to'); //$this->comment('from '.$from.'-01'); if (!is_iso_date($from . '-01')) { $this->comment('--from is invalid date format'); exit; } if (!is_iso_date($to . '-01')) { $this->comment('--to is invalid date format'); exit; } $from = \Carbon\Carbon::parse($from . '-01'); $to = \Carbon\Carbon::parse($to . '-01'); if ($from->gt($to)) { $this->comment('invalid date range: --from is greater than --to'); exit; } $this->comment($from->gt($to)); $this->comment($branch . ' ' . $from->format('Y-m-d')); //$this->comment('process: '.$this->option('branch').' from: '.$this->option('from')); }