subSeconds.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import { addSeconds } from "./addSeconds.js";
  2. /**
  3. * The {@link subSeconds} function options.
  4. */
  5. /**
  6. * Subtract the specified number of seconds from the given date.
  7. *
  8. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  9. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  10. *
  11. * @param date - The date to be changed
  12. * @param amount - The amount of seconds to be subtracted.
  13. * @param options - The options
  14. *
  15. * @returns The new date with the seconds subtracted
  16. *
  17. * @example
  18. * // Subtract 30 seconds from 10 July 2014 12:45:00:
  19. * const result = subSeconds(new Date(2014, 6, 10, 12, 45, 0), 30)
  20. * //=> Thu Jul 10 2014 12:44:30
  21. */
  22. export function subSeconds(date, amount, options) {
  23. return addSeconds(date, -amount, options);
  24. }
  25. // Fallback for modularized imports:
  26. export default subSeconds;