File size: 609 Bytes
7d51e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Utility functions for the application

/**

 * Formats active time in minutes to a human-readable string

 * @param {number} minutes - Active time in minutes

 * @returns {string} Formatted time string (e.g., "9m", "7h 6m")

 */
export const formatActiveTime = (minutes) => {
  if (!minutes || minutes === 0) return "0m";

  const hours = Math.floor(minutes / 60);
  const remainingMinutes = minutes % 60;

  if (hours === 0) {
    return `${remainingMinutes}m`;
  } else if (remainingMinutes === 0) {
    return `${hours}h`;
  } else {
    return `${hours}h ${remainingMinutes}m`;
  }
};