work_hour_calculator 0.0.4 copy "work_hour_calculator: ^0.0.4" to clipboard
work_hour_calculator: ^0.0.4 copied to clipboard

Flutter package that calculates how many working hours are spent between two DateTimes

work_hour_calculator #

pub package

Flutter package that calculates how many working hours are spent between two DateTimes.

Installation #

Add work_hour_calculator dependency to your Flutter project:

dependencies:
  work_hour_calculator: ^<latest-version>

Usage #

Import the package in your Flutter file, define a WorkWeekData, and use calculateWorkHours method to calculate work hours between two DateTimes:

import 'package:work_hour_calculator/work_hour_calculator.dart';

void main() {
    // Define work hours for 1 week.
    var workWeekData = WorkWeekData(
        workdays: [
            // Monday
            WorkDayData(
                workHours: [
                    WorkHourData(startHour: 9, endHour: 12), // 09.00-12.00
                    WorkHourData(startHour: 13, endHour: 18), // 13.00-18.00
                ],
            ),
            // Tuesday
            WorkDayData(
                workHours: [
                    WorkHourData(startHour: 9, endHour: 12),
                    WorkHourData(startHour: 13, endHour: 18),
                ],
            ),
            // Wednesday
            WorkDayData(
                workHours: [
                    WorkHourData(startHour: 9, endHour: 12),
                    WorkHourData(startHour: 13, endHour: 18),
                ],
            ),
            // Thursday
            WorkDayData(
                workHours: [
                    WorkHourData(startHour: 9, endHour: 12),
                    WorkHourData(startHour: 13, endHour: 18),
                ],
            ),
            // Friday
            WorkDayData(
                workHours: [
                    WorkHourData(startHour: 9, endHour: 12),
                    WorkHourData(startHour: 13, endHour: 18),
                ],
            ),
            // Saturday
            WorkDayData(
                workHours: [],
            ),
            // Sunday
            WorkDayData(
                workHours: [],
            ),
        ],
    );
    // Calculate work hours!
    final calculator = WorkHourCalculator();
    var workHours = calculator.calculateWorkHours(
        DateTime(2024, 10, 17, 15, 17),
        DateTime(2024, 10, 22, 10, 14),
        workWeekData,
    );
    // workHours == 19:57:00.000000
}

Issues #

For issues, file directly in the repository.

Find this library useful? ❤️ #

Support it by joining stargazers for this repository. ⭐️
Also, follow me on GitHub for my next project! 🤩

License #

Copyright 2024 hanmajid (Muhammad Farhan Majid)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1
likes
160
points
33
downloads

Publisher

verified publisherhanmajid.com

Weekly Downloads

Flutter package that calculates how many working hours are spent between two DateTimes

Repository (GitHub)
View/report issues

Topics

#calculator #work-hour #datetime

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on work_hour_calculator