My Hive Posts

    Bad Code to make Code Work

    We all have to write some bad code sometimes in order to make our code work. Similarly, I have to do that yesterday. I was getting the DateTime in yyyyMMddhhmmss format which is a very common format in Java. Now I need to convert that to a JavaScript Date for doing some computation on the dates.

    This is where I have to write a bad code where I have to slice Year, Month, Day, Hour, Minutes and Seconds and then using the date class converted it into the JavaScript Date and then computed it with other dates as shown below

    Date.UTC($entity.updated.slice(0, 4), $entity.updated.slice(4, 6) - 1, $entity.updated.slice(6, 8), $entity.updated.slice(8, 10), $entity.updated.slice(10, 12), $entity.updated.slice(12, 14)) >= Date.now().minusDays(7)

    Though I tried to write a good code by writing it in a function, because of SnapLogic limitation, have to write this in ugly format.