Skip to content

Commit

Permalink
Add comment regarding substr use for dates
Browse files Browse the repository at this point in the history
You'll notice that any dates field include more than just the numerical value:
/Date(1483242628000-0800)/.

To extract the date, we used the following suggestion:
http://stackoverflow.com/a/4511910/2395590

This helps us extract the date and return it back formatted as milliseconds.
  • Loading branch information
Justin Page committed Mar 9, 2017
1 parent 9ca154d commit 443e38f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/roku/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ exports.verifyPayment = function (payment, cb) {
return cb(new Error(resultObject.errorMessage));
}

// parse non-standard date property (i.e. /Date(1293034567877)/) in
// order to extract date by milliseconds
// parse non-standard date properties (i.e. /Date(1483242628000-0800)/)
// in order to extract value by milliseconds
resultObject.expirationDate = new Date(parseInt(resultObject.expirationDate.substr(6), 10)).getTime();
resultObject.originalPurchaseDate = new Date(parseInt(resultObject.originalPurchaseDate.substr(6), 10)).getTime();
resultObject.purchaseDate = new Date(parseInt(resultObject.purchaseDate.substr(6), 10)).getTime();
Expand Down

0 comments on commit 443e38f

Please sign in to comment.