longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Implement public API getter methods for start and end dates #463

Open TrueBurn opened 5 years ago

TrueBurn commented 5 years ago

I just upgraded to the newest version and the get API functions are no missing

data: function (params) { params.StartDate = moment($('#reportrange').data('dateRangePicker').getStart()).format("YYYY-MM-DD HH:mm"); params.EndDate = moment($('#reportrange').data('dateRangePicker').getEnd()).format("YYYY-MM-DD HH:mm"); //$("#reportrange").data('daterangepicker').endDate.format('DDMMMYYYY'); }

Can these be re-added to please advise how to access the start and end dates without having to decode the dom element value

monovertex commented 5 years ago

Hello, @TrueBurn. What version did you update from? I just checked some older tags (v10 and v5) and it seems the plugin never had those API methods. Perhaps the file you had in your project was modified directly and when you upgraded you lost those changes?

As far as I know, the only method to get the value right now is the input value, as that's the purpose of this plugin. I'll transform this issue into a feature request for date getters if you confirm that those changes were custom updates on the plugin.

TrueBurn commented 5 years ago

Hi @monovertex . I think I did have a custom extension now that I look at my version history.

It was a very basic method:

.call(this), p.alwaysOpen && t(0), Z(this).data("dateRangePicker", { setStart: function(e) { return "string" == typeof e && (e = Q(e, p.format).toDate()), p.end = !1, C(e), this }, getStart: function() { return p.start; }, setEnd: function(e, t) { var a = new Date; return a.setTime(p.start), "string" == typeof e && (e = Q(e, p.format).toDate()), T(a, e, t), this }, getEnd: function() { return p.end; },

So this is indeed not an issue.

monovertex commented 5 years ago

Alright. I'll convert this to a feature request issue and we'll add these in the future.