Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.js 626B

1234567891011121314151617181920
  1. // eslint-disable-next-line import/prefer-default-export
  2. export var t = function t(format) {
  3. return format.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
  4. return a || b.slice(1);
  5. });
  6. };
  7. export var englishFormats = {
  8. LTS: 'h:mm:ss A',
  9. LT: 'h:mm A',
  10. L: 'MM/DD/YYYY',
  11. LL: 'MMMM D, YYYY',
  12. LLL: 'MMMM D, YYYY h:mm A',
  13. LLLL: 'dddd, MMMM D, YYYY h:mm A'
  14. };
  15. export var u = function u(formatStr, formats) {
  16. return formatStr.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
  17. var B = b && b.toUpperCase();
  18. return a || formats[b] || englishFormats[b] || t(formats[B]);
  19. });
  20. };