Skip to content

Allowing creation of timesheet records with begin and end time#26

Open
vworldat wants to merge 1 commit into
kimai:masterfrom
vworldat:enhancement/record-start-and-end-time
Open

Allowing creation of timesheet records with begin and end time#26
vworldat wants to merge 1 commit into
kimai:masterfrom
vworldat:enhancement/record-start-and-end-time

Conversation

@vworldat

@vworldat vworldat commented Jan 5, 2026

Copy link
Copy Markdown

I added --begin/-b and --end/-e options to the kimai start command. This would resolve both #7 as well as parts of #8 (no --end option for kimai stop yet).

Had to add a phpstan baseline to ignore errors caused by kimai/api-php declaring nullable getters as non-nullable.

@kevinpapst kevinpapst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not test it, but look good to me.

Thanks @vworldat 👍

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/-b and --end/-e options to kimai start, with interactive refinement for invalid date inputs.
  • Updated CLI output to include an optional End timestamp.
  • 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.

Comment on lines 26 to 29
->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).')
Comment on lines +325 to +340
/**
* 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,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants