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

TIME SERVER task not passing on OS X #338

Open
Marqin opened this issue Aug 2, 2015 · 0 comments
Open

TIME SERVER task not passing on OS X #338

Marqin opened this issue Aug 2, 2015 · 0 comments

Comments

@Marqin
Copy link

Marqin commented Aug 2, 2015

I've tested this on my Linux PC and this code passes there. Problem is with OS X 10.10 MacBook Air learnyounode verify

Error I'm getting:

✗ Error connecting to localhost:20952: connect ECONNREFUSED

Your submission results compared to the expected:

                 ACTUAL                                 EXPECTED                
────────────────────────────────────────────────────────────────────────────────

   "2015-08-02 20:08"                  !=    ""                                 
   ""                                  !=                                       

────────────────────────────────────────────────────────────────────────────────

✗ Submission results did not match expected!

# FAIL

Your solution to TIME SERVER didn't pass. Try again!

with code:

var net = require('net');

function putZero ( x ) {
    return ( ( x < 10 ) ? "0" : "") + x;
}

var server = net.createServer( function( socket ) {
  var date = new Date();
  var timedate = date.getFullYear() + "-" + putZero(date.getMonth()+1) + "-" + putZero(date.getDate());
  timedate += " " + putZero(date.getHours()) + ":" + putZero(date.getMinutes());

  socket.write( timedate + "\n" );
  socket.end();
});

server.listen( process.argv[2] );

Of course, learnyounode run time.js prints right time. Also running with node time.js 20952 and telneting to it works OK on OS X.

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

1 participant