Relative Date v2 – now fuelled by Carbon

Relative Date for Kirby CMS

As my current job does not give me that much time for Kirby anymore, I am trying to consolidate my plugins these days. In my considerations, which plugins are worth it to keep them, the Relative Date one did not convince too much… but I think I found a solution.

With the just released version 2, Relative Date has been rewritten as a simple wrapper for the Carbon library with access to all its methods. Echoing a Relative Date instance will show the result of Carbon’s diffForHuman() method.

This allows me to keep the plugin but maintain it in a way that it remains usable, while the old code would have just suffered a slow death. I hope this helps everyone who needs a relative human-readable date.

Download and Documentation:

4 Likes

That’s probably a good thing in this case. It gives more possibilities with less work for you. :slight_smile:

I think it’s often about a decision to use a library or not. Here is my thoughs around it.

When not to use a library

  • It tries to solve much much more than intended. That’s often not good by performance or size.
  • It does not solve the problem completely, which often means some hacking is required.
  • It requres some other library to work, that is not needed for anything else.
  • If you want to be 100% in control of the code, then a library is not a good thing.

When to use a library

  • It solves the problem beautifully without extra fat or dependencies.
  • It’s takes time to solve it without a library for it.
  • If you don’t plan to maintain it that much. It requires the library to be maintained instead.

When I built GitHub - kirby-deprecated-plugins/kirby-keyword-map: SEO keyword map for Kirby CMS panel, I decided to use two libraries, which is a new record for me.

Both of them is not dependent of jQuery which is nice. In the panel we have access to jQuery so it does not really matter, but in general I prefer non dependent libraries.

Compare it to https://github.com/jenstornell/kirby-keyword-density where I did not use any libraries. It would not find keywords like “#Hello” or “Bye!” because of ending characters, which is an advantage of markjs.

The Carbon library is about 100 KB, but it’s run on the server side so it’s probably fine. I also like that it looks a bit like Kirby syntax $if->you()->know()->what()->i()->mean();

As my current job does not give me that much time for Kirby anymore

What do you work with?