DEV Community

Anton Ohorodnyk
Anton Ohorodnyk

Posted on • Originally published at

Parse time from different non timestamp formats

Liquid syntax error: Variable '{{<%20ref">different timestamp formats (seconds, milliseconds, microseconds, nanoseconds).

As I mentioned in the previous article, we can receive a string formatted date time from a client, when we expected string timestamp in seconds.

Obviously we hardcoded some solution to support the specific format on a server (as we are expecting to find this issue on production with a production client), but we still would like to make it more universan and forget about the problem for a while.

Let's implement the solution!

I'll use Golang for all code examples, but you can use any other languages base on the provided algorithm.

Issue overview

Before we will start writing code, we need to understand the issue.


To simplify current task, let's assume that we have a string field and we need to write a function that will support a multiple time formats.

There are our expectations:

  1. We have a string field where we expect to receive a RFC339 date time information.
  2. Our expectation is to see the timestamp in a range of dates and times between {% raw %}' was not properly terminated with regexp: /\}\}/

Top comments (0)