Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created May 23, 2018 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwaldron/9642d33d9ee2664704b74b476cfdcbca to your computer and use it in GitHub Desktop.
Save rwaldron/9642d33d9ee2664704b74b476cfdcbca to your computer and use it in GitHub Desktop.
JsValueRef __stdcall WScriptJsrt::MonotonicNowCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
HRESULT hr = E_FAIL;
JsValueRef returnValue = JS_INVALID_REFERENCE;
JsErrorCode errorCode = JsNoError;
IfJsrtErrorSetGo(ChakraRTInterface::JsGetUndefinedValue(&returnValue));
using std::chrono::duration_cast;
using std::chrono::milliseconds;
using std::chrono::steady_clock;
double now = duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
ChakraRTInterface::JsNumberToDouble(now, &returnValue);
return returnValue;
Error:
return returnValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment