You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calcCEPS.ts 784B

1234567891011121314151617181920212223242526
  1. // Function to calculate the formula
  2. function calculateCEPS(N, tFinLatest, tSendEv2) {
  3. // Calculate the time difference in milliseconds
  4. const timeDifference = tFinLatest - tSendEv2;
  5. // Ensure timeDifference is not zero to avoid division by zero
  6. if (timeDifference === 0) {
  7. throw new Error("Time difference cannot be zero.");
  8. }
  9. // Calculate CEPS
  10. const CEPS = N / timeDifference;
  11. return CEPS;
  12. }
  13. // Example usage
  14. const tFinLatest = new Date('2024-11-15T12:00:00Z'); // Replace with actual end time
  15. const tSendEv2 = new Date('2024-11-15T11:00:00Z'); // Replace with actual send time
  16. try {
  17. const result = calculateCEPS(1000, tFinLatest, tSendEv2);
  18. console.log("CEPS:", result);
  19. } catch (error) {
  20. console.error(error.message);
  21. }