fecha.d.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export declare type I18nSettings = {
  2. amPm: [string, string];
  3. dayNames: Days;
  4. dayNamesShort: Days;
  5. monthNames: Months;
  6. monthNamesShort: Months;
  7. DoFn(dayOfMonth: number): string;
  8. };
  9. export declare type I18nSettingsOptional = Partial<I18nSettings>;
  10. export declare type Days = [string, string, string, string, string, string, string];
  11. export declare type Months = [string, string, string, string, string, string, string, string, string, string, string, string];
  12. export declare function assign<A>(a: A): A;
  13. export declare function assign<A, B>(a: A, b: B): A & B;
  14. export declare function assign<A, B, C>(a: A, b: B, c: C): A & B & C;
  15. export declare function assign<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D;
  16. declare const defaultI18n: I18nSettings;
  17. declare const setGlobalDateI18n: (i18n: I18nSettingsOptional) => I18nSettings;
  18. declare const setGlobalDateMasks: (masks: {
  19. [key: string]: string;
  20. }) => {
  21. [key: string]: string;
  22. };
  23. /***
  24. * Format a date
  25. * @method format
  26. * @param {Date|number} dateObj
  27. * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
  28. * @returns {string} Formatted date string
  29. */
  30. declare const format: (dateObj: Date, mask?: string, i18n?: I18nSettingsOptional) => string;
  31. /**
  32. * Parse a date string into a Javascript Date object /
  33. * @method parse
  34. * @param {string} dateStr Date string
  35. * @param {string} format Date parse format
  36. * @param {i18n} I18nSettingsOptional Full or subset of I18N settings
  37. * @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
  38. */
  39. declare function parse(dateStr: string, format: string, i18n?: I18nSettingsOptional): Date | null;
  40. declare const _default: {
  41. format: (dateObj: Date, mask?: string, i18n?: Partial<I18nSettings>) => string;
  42. parse: typeof parse;
  43. defaultI18n: I18nSettings;
  44. setGlobalDateI18n: (i18n: Partial<I18nSettings>) => I18nSettings;
  45. setGlobalDateMasks: (masks: {
  46. [key: string]: string;
  47. }) => {
  48. [key: string]: string;
  49. };
  50. };
  51. export default _default;
  52. export { format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks };