Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running this produce error: var format = parseFormat(1397418578); #62

Closed
idanb11 opened this issue Mar 28, 2017 · 4 comments
Closed

running this produce error: var format = parseFormat(1397418578); #62

idanb11 opened this issue Mar 28, 2017 · 4 comments

Comments

@idanb11
Copy link
Contributor

idanb11 commented Mar 28, 2017

var format = parseFormat(1397418578);

c:\Users\Idanb11\Work\workspace\node_modules\moment-parseformat\lib\parseformat.js:79
  format = format.replace(regexUnixMillisecondTimestamp, 'x')
                  ^

TypeError: format.replace is not a function
    at parseFormat (c:\Users\Idanb11\Work\workspace\node_modules\moment-parseformat\lib\parseformat.js:79:19)
    at Object.<anonymous> (c:\Users\Idanb11\Work\workspace\server.js:5:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
@idanb11 idanb11 changed the title running this produce error: var format = parseFormat(1397418578); running this produce error: var format = parseFormat(1397418578); Mar 28, 2017
@gr2m
Copy link
Owner

gr2m commented Mar 28, 2017

What would you expect parseFormat(1397418578) to return? I’d suggest it should throw a better error message than format.replace. Would happily accept a pull request for it, you can add a test case to https://github.com/gr2m/moment-parseformat/blob/master/test/moment-parseformat-test.js

@idanb11
Copy link
Contributor Author

idanb11 commented Apr 1, 2017

Hi @gr2m ,

I expect that parseFormat(1397418578) will not crash the program and return the value X - exactly like when you run parseFormat("1397418578").

parseFormat should be able to work with Numbers and Strings

@gr2m
Copy link
Owner

gr2m commented Apr 1, 2017

I think we can add an input.toString() there and then a check for the x format. I don’t need that so I won’t work on it, but if you send a pull request with a test, I’d be happy to help get it merged

@gr2m
Copy link
Owner

gr2m commented Apr 2, 2017

@gr2m gr2m closed this as completed Apr 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants