Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Source Filtering with Date Field Error #2873

Open
jude86-7 opened this issue Sep 29, 2018 · 7 comments
Open

Data Source Filtering with Date Field Error #2873

jude86-7 opened this issue Sep 29, 2018 · 7 comments
Assignees
Milestone

Comments

@jude86-7
Copy link

jude86-7 commented Sep 29, 2018

Affected Symphony version(s) : 2.7.4
PHP version(s) : 5.6.37
OS(es) : Windows 10

I have a data source outputting two dates, in the debug view I have this;

      <ds-events-detail.event-start-date>
            <item handle="2018-10-14-09-59-53">2018-10-14 09:59:53</item>
      </ds-events-detail.event-start-date>
      <ds-events-detail.event-end-date>
            <item handle="2018-10-16-09-59-53">2018-10-16 09:59:53</item>
      </ds-events-detail.event-end-date>

I then create a new data source to filter between my outputted dates;

{$ds-events-detail.event-start-date} to {$ds-events-detail.event-end-date}

This is supposed to receive any events with dates that run within the chosen event's date range. It works if the date is within, but if the date is the same the results don't show. I think this is because of the time in the datasource output. Is there any way I can search without taking the time into consideration?

(EDIT: Format)

@nitriques
Copy link
Member

I think this is because of the time in the datasource output. Is there any way I can search without taking the time into consideration?

It sure does! Do you have the "use time" setting on ?

@michael-e I think we should "force" the hours when the time setting is not on. Here: https://github.com/symphonycms/symphony-2/blob/master/symphony/lib/toolkit/fields/field.date.php#L598 But I think we should do it at other places ?

@nitriques nitriques added this to the 2.7.8 milestone Oct 1, 2018
@nitriques nitriques self-assigned this Oct 1, 2018
@michael-e
Copy link
Member

Well, the setting is not called "use time" but "display time". And this answers a lot of questions IMHO.

In the database any timestamp is saved with the same precision, i.e. seconds, of course. What Symphony/PHP does if the time is missing upon saving is: use the current time. One might discuss this saving behaviour (and modify it in the core or via an extension), but I wouldn't suggest to trick anything when retrieving data — it feels like the wrong place to me.

So if we want a "better Date Field", we should first define developer/user expectations when saving a value. What should be the options? Maybe a "precision" setting (hours/minutes)? (Again this might be misleading, because the precision of a timestamp is always "seconds".)

@jude86-7
Copy link
Author

jude86-7 commented Oct 6, 2018

@nitriques @michael-e thank you for coming back on this one. The display time isn't checked. In this instance I am using the date field for 'start date' and 'end date' of an event. They are not time sensitive and will run all day or maybe over a few days.

I then use a chained datasource to bring out events that are occurring on the same day as another previously selected event. The entry is saved with the current time, as I haven't specified one when creating the entry. If the current times of adding the entry don't fit within each other the event doesn't show up. The datasource filter (chaining two datasources) seems to use both the date and the time when filtering, which seems correct but doesn't work in this use case. Does this make sense?

Basically I don't need the time in this situation, would it be possible to not assign a time at all if that option is checked on the field? Is this likely to be something that would be useful for other instances or is a time always required for the symphony core?

@jurajkapsz
Copy link
Contributor

Wouldn't be the "Use time" scenario an elengant solution? So to change "Display time" option to "Use time". When the time would be "used", it would be shown in the field and user would want to set it. Otherwise no time would be shown and a '00:00:00' would be filled in the background as the time.

This sounds good to me.
Or is this somehow tricky for the data?

It might be tricky when sorting such entries in publish index by date where "time is not used", but a secondary sorting via entry_id would I think do the thing.

Otherwise, maybe a quick dirty fix @jude86-7 , you can fill in zeroes of time into your fields until a better solution,?

@michael-e
Copy link
Member

Unfortunately I have no time to think about all possible side effects of such a change. But, if it's just a field option that takes effect upon saving, there might be none, so it might be completely backwards-compatible. :-)

For the field's configuration, one might as well think about multiple options:

  • force "zero" seconds
  • force "zero" minutes and seconds
  • force "zero" hours, minutes and seconds

@nitriques
Copy link
Member

So if we want a "better Date Field",

We already have one ;)

And we do set the value to force the time to be 0

I agree that the current behavior cannot be changed in 2.7.x

@jude86-7 You have 2 solutions: either enable the time and tell users to input 00:00. The filter will work. Or change to the datetime field, which does what you want.

Wouldn't be the "Use time" scenario an elengant solution? So to change "Display time" option to "Use time".

@jurajkapsz @michael-e I have not problem doing this in 3.0.x. I would not edit any existing data tho.

Should I send a PR ?

@nitriques nitriques modified the milestones: 2.7.8, 3.0.0 Oct 19, 2018
@jude86-7
Copy link
Author

@nitriques thank you I will give the datetime field a go, I don't think our user will remember to put 00:00 in everytime!

Thank you to everyone for your suggestions and feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants