fromUnixTime.d.cts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import type { ContextOptions } from "./types.js";
  2. /**
  3. * The {@link fromUnixTime} function options.
  4. */
  5. export interface FromUnixTimeOptions<DateType extends Date = Date>
  6. extends ContextOptions<DateType> {}
  7. /**
  8. * @name fromUnixTime
  9. * @category Timestamp Helpers
  10. * @summary Create a date from a Unix timestamp.
  11. *
  12. * @description
  13. * Create a date from a Unix timestamp (in seconds). Decimal values will be discarded.
  14. *
  15. * @param unixTime - The given Unix timestamp (in seconds)
  16. * @param options - An object with options. Allows to pass a context.
  17. *
  18. * @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).
  19. *
  20. * @returns The date
  21. *
  22. * @example
  23. * // Create the date 29 February 2012 11:45:05:
  24. * const result = fromUnixTime(1330515905)
  25. * //=> Wed Feb 29 2012 11:45:05
  26. */
  27. export declare function fromUnixTime<DateType extends Date = Date>(
  28. unixTime: number,
  29. options?: FromUnixTimeOptions<DateType> | undefined,
  30. ): DateType;