ember-localstorage-adapter icon indicating copy to clipboard operation
ember-localstorage-adapter copied to clipboard

Cannot store Date object

Open pewh opened this issue 10 years ago • 5 comments

If I store JS Date object, local storage just store '{ }'. Is there any solution to store Date object?

pewh avatar Nov 04 '14 08:11 pewh

+1

James1x0 avatar Dec 01 '14 22:12 James1x0

LS is, after all, just a string storage, so for date we'd have to serialize into string (e.g using ISO8601) and deserialize back when retrieving. A PR would be welcome :)

kurko avatar Jan 24 '15 17:01 kurko

Doesn't DS.attr('date') take care of this for us?

locks avatar Oct 05 '15 04:10 locks

@locks afaik, it's lost once you persist it. There's no transform for the date type. It would be easy tho, date.toISOString() / new Date(isoString)

James1x0 avatar Oct 05 '15 11:10 James1x0

Yes. The PR should be simple, though. Anyway who's needing this, please start a PR and we'll guide you through getting it merged :)

kurko avatar Nov 13 '15 14:11 kurko