e5123b761623640e12a523b64788d77094a95488d580948987311ceeac6f2a14703839ba83a27e59e871dbb444a91519427d94e42dc6e2b6b7a89450b22b53 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import { Moment } from './constructor';
  2. var proto = Moment.prototype;
  3. import { add, subtract } from './add-subtract';
  4. import { calendar } from './calendar';
  5. import { clone } from './clone';
  6. import {
  7. isBefore,
  8. isBetween,
  9. isSame,
  10. isAfter,
  11. isSameOrAfter,
  12. isSameOrBefore,
  13. } from './compare';
  14. import { diff } from './diff';
  15. import { format, toString, toISOString, inspect } from './format';
  16. import { from, fromNow } from './from';
  17. import { to, toNow } from './to';
  18. import { stringGet, stringSet } from './get-set';
  19. import { locale, localeData, lang } from './locale';
  20. import { prototypeMin, prototypeMax } from './min-max';
  21. import { startOf, endOf } from './start-end-of';
  22. import { valueOf, toDate, toArray, toObject, toJSON, unix } from './to-type';
  23. import { isValid, parsingFlags, invalidAt } from './valid';
  24. import { creationData } from './creation-data';
  25. proto.add = add;
  26. proto.calendar = calendar;
  27. proto.clone = clone;
  28. proto.diff = diff;
  29. proto.endOf = endOf;
  30. proto.format = format;
  31. proto.from = from;
  32. proto.fromNow = fromNow;
  33. proto.to = to;
  34. proto.toNow = toNow;
  35. proto.get = stringGet;
  36. proto.invalidAt = invalidAt;
  37. proto.isAfter = isAfter;
  38. proto.isBefore = isBefore;
  39. proto.isBetween = isBetween;
  40. proto.isSame = isSame;
  41. proto.isSameOrAfter = isSameOrAfter;
  42. proto.isSameOrBefore = isSameOrBefore;
  43. proto.isValid = isValid;
  44. proto.lang = lang;
  45. proto.locale = locale;
  46. proto.localeData = localeData;
  47. proto.max = prototypeMax;
  48. proto.min = prototypeMin;
  49. proto.parsingFlags = parsingFlags;
  50. proto.set = stringSet;
  51. proto.startOf = startOf;
  52. proto.subtract = subtract;
  53. proto.toArray = toArray;
  54. proto.toObject = toObject;
  55. proto.toDate = toDate;
  56. proto.toISOString = toISOString;
  57. proto.inspect = inspect;
  58. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  59. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  60. return 'Moment<' + this.format() + '>';
  61. };
  62. }
  63. proto.toJSON = toJSON;
  64. proto.toString = toString;
  65. proto.unix = unix;
  66. proto.valueOf = valueOf;
  67. proto.creationData = creationData;
  68. // Era
  69. import { getEraName, getEraNarrow, getEraAbbr, getEraYear } from '../units/era';
  70. proto.eraName = getEraName;
  71. proto.eraNarrow = getEraNarrow;
  72. proto.eraAbbr = getEraAbbr;
  73. proto.eraYear = getEraYear;
  74. // Year
  75. import { getSetYear, getIsLeapYear } from '../units/year';
  76. proto.year = getSetYear;
  77. proto.isLeapYear = getIsLeapYear;
  78. // Week Year
  79. import {
  80. getSetWeekYear,
  81. getSetISOWeekYear,
  82. getWeeksInYear,
  83. getWeeksInWeekYear,
  84. getISOWeeksInYear,
  85. getISOWeeksInISOWeekYear,
  86. } from '../units/week-year';
  87. proto.weekYear = getSetWeekYear;
  88. proto.isoWeekYear = getSetISOWeekYear;
  89. // Quarter
  90. import { getSetQuarter } from '../units/quarter';
  91. proto.quarter = proto.quarters = getSetQuarter;
  92. // Month
  93. import { getSetMonth, getDaysInMonth } from '../units/month';
  94. proto.month = getSetMonth;
  95. proto.daysInMonth = getDaysInMonth;
  96. // Week
  97. import { getSetWeek, getSetISOWeek } from '../units/week';
  98. proto.week = proto.weeks = getSetWeek;
  99. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  100. proto.weeksInYear = getWeeksInYear;
  101. proto.weeksInWeekYear = getWeeksInWeekYear;
  102. proto.isoWeeksInYear = getISOWeeksInYear;
  103. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  104. // Day
  105. import { getSetDayOfMonth } from '../units/day-of-month';
  106. import {
  107. getSetDayOfWeek,
  108. getSetISODayOfWeek,
  109. getSetLocaleDayOfWeek,
  110. } from '../units/day-of-week';
  111. import { getSetDayOfYear } from '../units/day-of-year';
  112. proto.date = getSetDayOfMonth;
  113. proto.day = proto.days = getSetDayOfWeek;
  114. proto.weekday = getSetLocaleDayOfWeek;
  115. proto.isoWeekday = getSetISODayOfWeek;
  116. proto.dayOfYear = getSetDayOfYear;
  117. // Hour
  118. import { getSetHour } from '../units/hour';
  119. proto.hour = proto.hours = getSetHour;
  120. // Minute
  121. import { getSetMinute } from '../units/minute';
  122. proto.minute = proto.minutes = getSetMinute;
  123. // Second
  124. import { getSetSecond } from '../units/second';
  125. proto.second = proto.seconds = getSetSecond;
  126. // Millisecond
  127. import { getSetMillisecond } from '../units/millisecond';
  128. proto.millisecond = proto.milliseconds = getSetMillisecond;
  129. // Offset
  130. import {
  131. getSetOffset,
  132. setOffsetToUTC,
  133. setOffsetToLocal,
  134. setOffsetToParsedOffset,
  135. hasAlignedHourOffset,
  136. isDaylightSavingTime,
  137. isDaylightSavingTimeShifted,
  138. getSetZone,
  139. isLocal,
  140. isUtcOffset,
  141. isUtc,
  142. } from '../units/offset';
  143. proto.utcOffset = getSetOffset;
  144. proto.utc = setOffsetToUTC;
  145. proto.local = setOffsetToLocal;
  146. proto.parseZone = setOffsetToParsedOffset;
  147. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  148. proto.isDST = isDaylightSavingTime;
  149. proto.isLocal = isLocal;
  150. proto.isUtcOffset = isUtcOffset;
  151. proto.isUtc = isUtc;
  152. proto.isUTC = isUtc;
  153. // Timezone
  154. import { getZoneAbbr, getZoneName } from '../units/timezone';
  155. proto.zoneAbbr = getZoneAbbr;
  156. proto.zoneName = getZoneName;
  157. // Deprecations
  158. import { deprecate } from '../utils/deprecate';
  159. proto.dates = deprecate(
  160. 'dates accessor is deprecated. Use date instead.',
  161. getSetDayOfMonth
  162. );
  163. proto.months = deprecate(
  164. 'months accessor is deprecated. Use month instead',
  165. getSetMonth
  166. );
  167. proto.years = deprecate(
  168. 'years accessor is deprecated. Use year instead',
  169. getSetYear
  170. );
  171. proto.zone = deprecate(
  172. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  173. getSetZone
  174. );
  175. proto.isDSTShifted = deprecate(
  176. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  177. isDaylightSavingTimeShifted
  178. );
  179. export default proto;