Random thought, is there a google translate UI but for date time string?

So I have been working with some dates data lately (Like many other people do). I was wondering if there is a tool that can let you select a date format that you are in now from a drop down list of date formats (Like picking a foreign language on google translate), then pick a “destination” format from another drop down that you want it to transform into.

Then it will automatically generate a function snippet for you to copy and paste the transformation that you want into your code as a transform_date function (you can name the function from the UI too)

For example, mmm-dd to yyyy-mm-dd, and you get the function to copy and paste

image

Hope you all get what I mean haha, just a sudden thought.

I think I like it…! Would it be for python for v0.1?

But, hmm, how to translate from mmm-dd to yyyy-mm-dd?? What’s the correct answer?

All dates in your program should be stored as UNIX epochs anyway :smirk: and so your function should parse into epoch, and print into whatever output you need. It’s the automatic parsing that’s tricky…

Have a look at the lubridate library in R for a really nice interface, even if you use other languages:

This is a question of locale, not language. There is no way to get a correct answer from one date without a minimum of training or context. If I just give you " 02/12/2019 " without any other form of context, it is impossible to decide whether I’m referring to 2 Dec (European) or 12 Feb (American).

2 Likes

Exactly, this is a parsing issue. In Python it’s strptime followed by strftime: https://stackoverflow.com/questions/14524322/how-to-convert-a-date-string-to-different-format

Formats could be guessed using context, just as Google Translate infers language of a passage.