Skip to content

Commit 3e4e774

Browse files
author
Hunter
committed
Use canonical toISOString instead of duplicate implementation
Remove duplicate toISOString helper and use the existing canonical version from wtf-bindings.h. The canonical version is more robust: - Already uses snprintf safely - Uses vm.dateCache.msToGregorianDateTime() instead of gmtime() - Handles edge cases like years outside 0-9999 range per ES spec - Returns character count for validation This addresses the CodeRabbit review feedback about API inconsistency and code duplication.
1 parent 4d60b6f commit 3e4e774

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/bun.js/bindings/BunProcessReportObjectWindows.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "BunProcess.h"
66
#include "ZigGlobalObject.h"
77
#include "FormatStackTraceForJS.h"
8+
#include "wtf-bindings.h"
89
#include "headers.h" // For Bun__Process__createExecArgv and other exports
910
#include "JavaScriptCore/JSCJSValue.h"
1011
#include "JavaScriptCore/JSObject.h"
@@ -35,22 +36,7 @@ using namespace JSC;
3536
// External functions
3637
extern "C" EncodedJSValue Bun__Process__createExecArgv(JSGlobalObject*);
3738

38-
// Helper function to convert time to ISO string
39-
static void toISOString(JSC::VM& vm, double time, char* buffer)
40-
{
41-
time_t seconds = static_cast<time_t>(time / 1000);
42-
int milliseconds = static_cast<int>(time) % 1000;
43-
struct tm* timeinfo = gmtime(&seconds);
44-
45-
sprintf(buffer, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
46-
timeinfo->tm_year + 1900,
47-
timeinfo->tm_mon + 1,
48-
timeinfo->tm_mday,
49-
timeinfo->tm_hour,
50-
timeinfo->tm_min,
51-
timeinfo->tm_sec,
52-
milliseconds);
53-
}
39+
5440

5541
JSValue constructReportObjectWindows(VM& vm, Zig::GlobalObject* globalObject, Process* process)
5642
{

0 commit comments

Comments
 (0)