Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library doesn't work, false result #6

Open
vipera7 opened this issue Dec 11, 2023 · 0 comments
Open

Library doesn't work, false result #6

vipera7 opened this issue Dec 11, 2023 · 0 comments

Comments

@vipera7
Copy link

vipera7 commented Dec 11, 2023

Hello,

I'm attempting to utilize the library for calculating durations between two dates. Here's an example:

<?php
require 'vendor/autoload.php';

use Sifex\SlaTimer\SLA;
use Sifex\SlaTimer\SLABreach;
use Sifex\SlaTimer\SLASchedule;

/**
 * Create a new SLA between 9am and 5:00pm weekdays
 */
$sla = SLA::fromSchedule(
    SLASchedule::create()->from('09:00:00')->to('17:00:00')->onWeekdays()
);

$dateTime_start = DateTime::createFromFormat('H:i:s d-m-Y', '16:58:00 01-12-2023');
$dateTime_start->setTimezone(new DateTimeZone('UTC'));
$utcFormat_start = $dateTime_start->format('H:i:s d-m-Y');

$dateTime_end = DateTime::createFromFormat('H:i:s d-m-Y', '09:01:01 04-12-2023');
$dateTime_end->setTimezone(new DateTimeZone('UTC'));
$utcFormat_end = $dateTime_end->format('H:i:s d-m-Y');

$duration = $sla->duration($utcFormat_start, $utcFormat_end);

var_dump($duration->totalSeconds);
var_dump($duration->forHumans());

Output :

int(120)
string(9) "2 minutes"

The expected result is 3 minutes 1 second. Can you help me understand why it's calculating this way?

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

No branches or pull requests

1 participant