v8::Date C++ API additions

57 views
Skip to first unread message

James Snell

unread,
Feb 24, 2024, 2:30:14 PM2/24/24
to v8-dev
Hello all :-) 

Before going through and doing the work, I wanted to ask if the project would be open to a contribution for the following additions to the v8::Date C++ API

1. `v8::Date::ToUTCString()` ... this would be nearly identical to the existing `v8::Date::ToISOString()` method except it would generate the UTC format. This requires only a couple lines of code added to api.cc.

2. `static v8::Date::Parse(context, string)` ... this would create a new `v8::Date` (like `v8::Date::New(..)` from an input string (equivalent to `new Date(string)` in JS). This would likely require moving the `ParseDateTimeString(...)` private method currently located in builtins-date.cc to a public API that can be accessed from api.cc.

Currently, an embedder wishing to accessing these has to grab the appropriate methods off the `Date` prototype in javascript which is a bit... cumbersome.

I've implemented a draft patch of the suggested APIs here: https://github.com/cloudflare/workerd/pull/1724/files

Leszek Swirski

unread,
Feb 26, 2024, 6:05:22 AM2/26/24
to v8-...@googlegroups.com
Hi James,

Thanks for asking, this seems like a reasonable set of APIs to add, I'll happily review a patch.

- Leszek

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/c545cb02-ec6e-415a-8aa4-0084a5c725b1n%40googlegroups.com.

James Snell

unread,
Feb 26, 2024, 10:01:47 AM2/26/24
to v8-dev
Excellent, thank you. if this week is kind to me I'll hopefully have the patch set ready to review by mid to late week.
Reply all
Reply to author
Forward
0 new messages