Conversation
kevinpapst
left a comment
There was a problem hiding this comment.
I did not test it, but look good to me.
Thanks @vworldat 👍
There was a problem hiding this comment.
Pull request overview
Adds support for creating timesheet records with explicit begin/end timestamps via the kimai start command, enabling scripted/bulk inserts and “forgot to start/stop” workflows discussed in #7 and parts of #8.
Changes:
- Added
--begin/-band--end/-eoptions tokimai start, with interactive refinement for invalid date inputs. - Updated CLI output to include an optional
Endtimestamp. - Added PHPStan baseline configuration to suppress a nullsafe-call finding originating from upstream API typings.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Command/TimesheetCommandTrait.php | Adds a helper for parsing DateTime values (currently implemented recursively). |
| src/Command/StartCommand.php | Introduces --begin/--end options, parses them into the form, and prints End in output. |
| README.md | Documents new --begin/--end options with examples and refinement prompt behavior. |
| phpstan.neon | Includes the baseline file in PHPStan configuration. |
| phpstan-baseline.neon | Suppresses a specific PHPStan nullsafe-call rule for StartCommand.php. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ->setName('start') | ||
| ->setDescription('Starts a new timesheet') | ||
| ->setHelp('This command lets you start a new timesheet') | ||
| ->setHelp('This command lets you start a new timesheet and optionally end it immediately.') | ||
| ->addOption('customer', 'c', InputOption::VALUE_OPTIONAL, 'The customer to filter the project list, can be an ID or a search term or empty (you will be prompted for a customer).') |
| /** | ||
| * Try to convert the given string into a DateTime object and recursively ask for clarification if necessary. | ||
| */ | ||
| private function parseAndRefineDateTime(SymfonyStyle $io, string $begin, string $valueName): \DateTime | ||
| { | ||
| try { | ||
| return new \DateTime($begin); | ||
| } catch (\Exception $e) { | ||
| } | ||
|
|
||
| return $this->parseAndRefineDateTime( | ||
| $io, | ||
| $io->ask(\sprintf('Value "%s" for field "%s" is not a valid DateTime. Please refine:', $begin, $valueName), $begin), | ||
| $valueName, | ||
| ); | ||
| } |
|
Thanks for this PR and it works. one fix is needed to make it to use the timezone setup of the machine instead of always UTC. It would be great if this PR can be merged. |
|
@parthitce do you want to take over and send an updated PR? |
Yeah sure. I will retain the original author and add the fix. may be additional signed-off. does that work? |
|
Did you check what happens if the current timezone is different from the API users timezone? |
Addressed with #36 , IMO this PR can be closed |
I added
--begin/-band--end/-eoptions to thekimai startcommand. This would resolve both #7 as well as parts of #8 (no--endoption forkimai stopyet).Had to add a phpstan baseline to ignore errors caused by
kimai/api-phpdeclaring nullable getters as non-nullable.