Skip to main content

7. eBA Work Day Calculator

#7 eBA Work Day Calculator

eBA Workday Calculator is an application programming interface (API) that helps calculate the times of the operations performed. With this API, the time between two given dates or the result of the resulting date can be calculated when an additional time is added to a given date. Date calculations are made taking into account weekly working days, working hours, public holidays and leave days of employees. Results can be calculated in days or minutes.

7.1. WorkDayCalculator

7.1.1. Methods

• GetDays(eBADBProvider, DateTime, DateTime, CalculationOption, bool, string)

Definition: Returns the time between two given dates in days, taking into account other parameters. Declaration: public static int GetDays(eBADBProvider dbProvider, DateTime startDate, DateTime endDate, CalculationOption option, bool holidays, string objectID) Parameters dbProvider: Specifies the database connection object of type eBADB.eBADBProvider from the eBADB.dll reference. startDate: Specifies the calculation start date. endDate: Specifies the calculation end date. option: Specifies the calculation option information of type eBAWorkdayCalculator.CalculationOption.
holidays: Specifies whether holidays are included in the calculation. objectID: When holidays are considered in calculations, if a user id is given as the objectID value, it is taken into account in the calculations of that user's specific holidays. Return Type: System.Integer

Note For detailed information about "eBAWorkdayCalculator.CalculationOption", see "CalculationOption".

• GetMinutes(eBADBProvider, DateTime, DateTime, CalculationOption, bool, string)

Definition : Returns the time between two given dates in minutes, taking into account other parameters. Declaration : public static int GetMinutes(eBADBProvider dbProvider, DateTime startDate, DateTime endDate, CalculationOption option, bool holidays, string objectID) Parameters
dbProvider: Specifies the database connection object of type eBADB.eBADBProvider from the eBADB.dll reference. startDate: Specifies the calculation start date. endDate: Specifies the calculation end date. option: Specifies the calculation option information of type eBAWorkdayCalculator.CalculationOption. holidays: Specifies whether holidays are included in the calculation. objectID: When holidays are considered in calculations, if a user id is given as the objectID value, that user's special holidays are taken into account in the calculations. Return Type: System.Integer

Note For detailed information about "eBAWorkdayCalculator.CalculationOption", see "CalculationOption".

• AddTime(eBADBProvider, DateTime, int, int, CalculationOption, bool, string)

Definition: Adds time in days and minutes to the date value according to the calculation criteria and creates a new date value. Declaration: public static DateTime AddTime(eBADBProvider dbProvider, DateTime startDate, int days, int minutes, CalculationOption option, bool holidays, string objectID) Parameters dbProvider: Specifies the database connection object of type eBADB.eBADBProvider from the eBADB.dll reference. startDate: Specifies the calculation start date. days: Specifies the number of days to add. minutes: Specifies the number of minutes to add. option: Specifies the calculation option of type eBAWorkdayCalculator.CalculationOption. holidays: Specifies whether holidays are included in the calculation. objectID: When holidays are considered in calculations, as the objectID value If a user ID is provided, it is taken into account in the calculations of that user's special holidays. Return Type: System.DateTime

Note For detailed information about "eBAWorkdayCalculator.CalculationOption", see "CalculationOption".

7.2. CalculationOption

CalculationOption is an enum type that specifies methods for calculating dates.

Values

• WorkingHours: The calculation is based on the weekly working days and working hours defined in the system.

Example: In a company, the working hours are 08:00 – 18:00 on weekdays and 08:00 – 13:00 on Saturdays. Calculations will be made taking into account these hours. Thus, the hours worked performed can be calculated.

• WorkDays: Calculates only according to weekly working days.

Example: In a company, the working hours are 08:00 – 18:00 on weekdays and 08:00 – 13:00 on Saturdays. Since only working days are taken into account, Saturday will also be counted as a day, but Sunday will not be included in the calculations. (Performed working days will be calculated as 6.)

• Absolute: Date differences are used in calculations without taking working hours into account.

7.3. Example Usage

In the calculations, the duration of days and minutes between the two dates is calculated, taking into account the working hours. eBADBProvider db = DatabaseTier.CreateConnectionAndOpen(); try { int days; double minutes; DateTime startDate = new DateTime(2014, 8, 3); DateTime endDate = new DateTime(2014, 8, 9); string objectID = "huzal"; CalculationOption option = CalculationOption.WorkingHours; days = WorkDayCalculator.GetDays(db, startDate, endDate, option, true, objectID); minutes = WorkDayCalculator.GetMinutes(db, startDate, endDate, option, calculateHolidaysCheckBox.Checked, objectID) MessageBox.Show(string. format("Total:\nin Days: {0}\nin Hours: {1}\nin Minutes: {2}", days, minutes / 60d, minutes), "Calculation Result"); } finally { DatabaseTier.CloseConnection(db); }

In the calculations, the duration of days and minutes between the two dates is calculated, taking into account the working hours. public void DateCalculate() { eBADBProvider db = DatabaseTier.CreateConnectionAndOpen(); Try { int days; double minutes; DateTime startDate = new DateTime(2014, 8, 3); DateTime endDate = new DateTime(2014, 8, 9); string objectID = "huzal"; CalculationOption option = CalculationOption.WorkingHours; days = WorkDayCalculator.GetDays(db, startDate, endDate, option, true, objectID); minutes = WorkDayCalculator.GetMinutes(db, startDate, endDate, option, calculateHolidaysCheckBox.Checked, objectID) MessageBox.Show(string. Format("Total:\nin Days: {0}\nin Hours: {1}\nin Minutes: { 2}", days, minutes / 60d, minutes), "Calculation Result"); } finally { DatabaseTier.CloseConnection(db); } }