CalOohPay API Documentation - v2.1.0
    Preparing search index...

    Class OnCallUser

    Represents a user and their on-call duty periods with calculated compensation metrics.

    This class is the primary data structure for tracking a user's on-call assignments and computing their out-of-hours (OOH) work. It aggregates multiple on-call periods and provides summary statistics for weekday and weekend OOH shifts.

    The class distinguishes between:

    • Weekdays (Monday-Thursday): Paid at £50 per OOH day
    • Weekends (Friday-Sunday): Paid at £75 per OOH day

    An OOH day is counted when a shift:

    1. Spans across days (not same-day start and end)
    2. Extends past end of work hours (17:30)
    3. Is longer than 6 hours
    const user = new OnCallUser(
    'PXXXXXX',
    'John Doe',
    [
    new OnCallPeriod(
    new Date('2024-08-01T17:30:00Z'),
    new Date('2024-08-05T09:00:00Z'),
    'Europe/London'
    )
    ]
    );

    console.log(user.getTotalOohWeekDays()); // 1 (Thursday)
    console.log(user.getTotalOohWeekendDays()); // 3 (Fri, Sat, Sun)
    Index

    Constructors

    Properties

    id: string

    Unique identifier for the user from PagerDuty.

    'PXXXXXX'
    
    name: string

    Display name of the user.

    'John Doe'
    

    Accessors

    Methods

    • Adds a single on-call period to the user's schedule.

      Parameters

      Returns void

      user.addOnCallPeriod(new OnCallPeriod(start, end, 'Europe/London'));
      
    • Adds multiple on-call periods to the user's schedule.

      Parameters

      Returns void

      user.addOnCallPeriods([period1, period2, period3]);
      
    • Calculates the total number of out-of-hours weekdays (Monday-Thursday).

      Sums up all OOH weekdays across all on-call periods for this user. Each qualifying OOH day on Mon-Thu counts as one unit at £50 compensation.

      Returns number

      Total count of OOH weekdays

      const weekdayCount = user.getTotalOohWeekDays();
      const weekdayCompensation = weekdayCount * 50; // £50 per weekday
    • Calculates the total number of out-of-hours weekend days (Friday-Sunday).

      Sums up all OOH weekend days across all on-call periods for this user. Each qualifying OOH day on Fri-Sun counts as one unit at £75 compensation.

      Returns number

      Total count of OOH weekend days

      const weekendCount = user.getTotalOohWeekendDays();
      const weekendCompensation = weekendCount * 75; // £75 per weekend day
    • Returns a human-readable string representation of the user and their on-call schedule.

      Returns string

      Formatted string with user details and all on-call periods

      console.log(user.toString());
      // Output:
      // (PXXXXXX) John Doe was on call during:
      // On call period from Thu Aug 01 2024 17:30:00 to Mon Aug 05 2024 09:00:00 (Europe/London)
      // Number of OOH Weekdays (Mon-Thu): 1
      // Number of OOH Weekends (Fri-Sun): 3