• Drupal 8.1.3
  • TimelineJS 8.x-3.x (downloaded today)

I created a content type, added Date fields (Date only, no time). I created three nodes, all date fields properly filled in. I added them to a view, and date fields are set to display as 'HTML Year.' Fields are mapped.
I continually getting these errors on the view and page:

  • VIEW: The date "" does not conform to a PHP supported date and time format.
  • PAGE: Error: Timeline configuration has no events

Notice: Undefined variable: date_string in Drupal\views_timelinejs\Plugin\views\style\TimelineJS->buildDate() (line 452 of /localpath/docroot/modules/contrib/views_timelinejs/src/Plugin/views/style/TimelineJS.php).

I also tried simple plain text fields with a Year (in part b/c I need date pre-1970, and Pre-CE/AD too), but that did not work.

Note: if it makes any difference, I downloaded the module via Composer, not the tarball.

Comments

mariagwyn created an issue. See original summary.

dcam’s picture

I can't decide whether I'm happy that someone downloaded the new version or disappointed that someone already found a bug.

Actually, I think I know what's going on. Let me test real quick. I'm pretty sure it's something that I meant to document, but didn't. Also something that I probably should have built in a special handler for.

edit: By "real quick" I mean that I'm going to have to totally set up a whole new timeline and it's going to take me a little while. My D8 database got corrupted by an unrelated OS problem.

dcam’s picture

Ok, when working with the Date field, go into the field's settings in Views. Expand Rewrite results. Check Strip HTML tags.

Date fields end up wrapped in an HTML tag so that some metadata format can be included with it. I must have told myself a dozen times to document that and also to strip tags in the plugin code so people wouldn't run into the problem that you just did. I never got around to doing either one. I'm sorry for that.

I'll work on figuring out what's wrong with using a plain text field for the date next. I wouldn't have expected any problem with that, but I'll admit that I haven't tested all use cases yet.

mariagwyn’s picture

dcam: sorry to make you happy/sad! I have been waiting for this version, so pounced when I saw it released. Thanks for the quick response!

Your fix worked.

Just FYI, I tried stripping html on the text fields as well. It works, sort of. When I put a year, say, "1000", it shows it as 10:00AM. So, I clearly need to work on formatting the output to somehow communicate just 'year', OR, I need to add the date in some phpformat that it recognizes.

I will play a bit more and see what I come up with and get back to you. If you come up with a solution first, let me know!

Thanks again!

dcam’s picture

You actually uncovered a couple of problems. Aside from the tag-stripping (which I've already written the code to patch), that error message was supposed to display the value being parsed. It wasn't displaying it because that $date_string variable got removed during the D8 port due to changes in field rendering. If you had been able to see what it was trying to parse, then you probably would have easily figured out that you needed to strip the tags yourself. They show up clearly in the error message once it's working properly.

I have been looking into the year problem. From http://php.net/manual/en/datetime.formats.date.php:

The "Year (and just the year)" format only works if a time string has already been found -- otherwise this format is recognised as HH MM.

I will try to figure out if there's anything we can do about this, but at the moment the only suggestion that I have is to use a complete date, "1000-01-01" and then override the display with a Display Date field. Not ideal, but that should work.

Unfortunately, I also tested a BCE date and that didn't work either, so I need to look into how the PHP DateTime class handles BCE dates, if it does at all. I'll keep you posted.

dcam’s picture

Ok, the problem I experienced with the BCE date was a result of not knowing that they must be entered with a four-digit year, e.g. -0315-05-24. Once I learned that, I was able to display BCE dates on the timeline with no problem.

I'll continue to look into the year-only issue, but at the moment I don't think there's anything that can be done except override with a Display Date. In the meantime, I'll commit the tag stripping to dev.

By the way, thanks for a thorough bug report!

  • dcam committed 577caa8 on 8.x-3.x
    Issue #2759545: Strip HTML tags from dates.
    

  • dcam committed b59fcf0 on 7.x-3.x
    Issue #2759545: Strip HTML tags from dates.
    
mariagwyn’s picture

Dcam, thanks, I now have early AD and BCE dates working, in the text field. I could never get them in an actual date field since it seems that the php library only goes to 1970, and while you can add another library, that only allows as early as 100CE. I need earlier.

Also, I am going to test the change. What should I expect:

  1. That I still need to 'strip html' in the view?
  2. That I no longer need to 'strip html' in the view?

I will get back to you.

dcam’s picture

If you pull the dev version then you should no longer need to strip tags.

mariagwyn’s picture

Tested, confirmed works without stripping tags on text field. I didn't try the date field due to the era restriction, but I assume it works too.

dcam’s picture

Status: Active » Fixed

Marking this one as Fixed. Starting a new issue for the year-only problem. Thanks again, @mariagwyn!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.