63476a56db434a94cf120c81bcf647113fe7fc461965688078a35527dd2d37326e9eabf8646132b422fcf902f3c7618a25e0620ef023e483aa6abded0e87c7 829 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.getNormalizedDate = getNormalizedDate;
  4. /* eslint-disable import/prefer-default-export */
  5. /**
  6. * Get normalized Date object for the ISO formatted date strings.
  7. * Natively, the date object parsed from a ISO 8601 string will be offsetted by the timezone difference, which may result in returning a wrong date.
  8. * See: Github issue #3338.
  9. *
  10. * @param {String} dateString String representing the date.
  11. * @returns {Date} The proper Date object.
  12. */
  13. function getNormalizedDate(dateString) {
  14. var nativeDate = new Date(dateString);
  15. // NaN if dateString is not in ISO format
  16. if (!isNaN(new Date(dateString + "T00:00").getDate())) {
  17. // Compensate timezone offset
  18. return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000);
  19. }
  20. return nativeDate;
  21. }