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

One of the examples returns [Function] instead of an integer. #320

Open
detrout opened this issue Nov 10, 2019 · 2 comments
Open

One of the examples returns [Function] instead of an integer. #320

detrout opened this issue Nov 10, 2019 · 2 comments

Comments

@detrout
Copy link

detrout commented Nov 10, 2019

I was turning the examples into a test and ran into an error.

var ok = require("assert");
var eq = require("assert").equal;
var tz = require("timezone");

var y2k = tz("2000-01-01");
eq( y2k, 946684800000 );
eq( y2k, Date.UTC(2000, 0, 1));

eq( tz("1970-01-01"), 0);
ok( tz("1969-7-21 02:56") < 0);

Thrown:
{ [AssertionError [ERR_ASSERTION]: false == true]
  generatedMessage: true,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==' }
> tz("1969-7-21 02:56")
[Function]

I tried it both with a copy I was building for a Debian package, and a copy installed into a new directory with npm install timezone.

@simevo
Copy link

simevo commented Nov 10, 2019

actually in the examples it's 1969-07-21 with 0:
https://github.com/bigeasy/timezone/blob/master/src/synopsis.js#L75

if you change it this way, the code works

TBH I would have expected it to work without zero as well, so this issue could be worth considering for useability.

it's also a mystery why when fed 1969-7-21 02:56 without zero, it returns a function that when evaluated returns 1.0.22 (the module version number); it this input is to be really considered invalid (which I tend to disagree) I would expect an exception or some error.

@detrout
Copy link
Author

detrout commented Nov 10, 2019

Ah I did typo the example.

I too would've expected an exception for unparsable input as well. Returning a function that returns the version is pretty odd behavior.

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