nodejs-polars icon indicating copy to clipboard operation
nodejs-polars copied to clipboard

Support for the `Duration` data type

Open roll opened this issue 1 month ago • 4 comments

Describe your feature request

It seems to be the Duration data types is not exposed to JS - https://github.com/search?q=repo%3Apola-rs%2Fnodejs-polars%20duration&type=code

roll avatar Oct 25 '25 10:10 roll

@roll Do you mind putting a PR for it? I see a lot of references to duration in Python Polars and not sure which feature we need to add. Thx

Bidek56 avatar Oct 26 '25 13:10 Bidek56

I made good progress on adding Duration data type, but since JS does not have a duration data type, not sure how to proceed. Python has timedelta and there is experimental JS Temporal.Duration but it's a long way from proceeding.

Bidek56 avatar Oct 31 '25 22:10 Bidek56

Hi, sorry I didn't have a chance yet to take a look.

My thinking was that we can use a Temporal polyfill:

  • https://github.com/fullcalendar/temporal-polyfill
  • https://github.com/js-temporal/temporal-polyfill

The working group says that "This proposal is now in the hands of ECMAScript engine implementers, so the bar for making API changes is extremely high" making that this exact API will become a standard JS soon.

As an other option, can it just be a string in JS? At least, for my case it will be sufficient to be able to manipulate durations within dataframes. Of course, full implementation would be nicer in-general.

roll avatar Nov 01 '25 07:11 roll

Maybe we do not need Temporal.Duration since we are already constructing Duration type. Enhancing the Duration type to include all the attributes maybe sufficient.

Bidek56 avatar Nov 01 '25 14:11 Bidek56

I have a WIP branch for duration type, but tests are failing. Need to figure out why.

Bidek56 avatar Nov 08 '25 15:11 Bidek56

Great news! I try to test it next week

roll avatar Nov 08 '25 16:11 roll

Thanks!

roll avatar Nov 11 '25 14:11 roll