[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] convert from 'date +"%H-%M %m-%d-%Y"' to seconds from 1970

On 5/5/20 5:18 AM, Beyer, Christoph wrote:

thanks, maybe my question was a bit misleading, I know there are a couple of ways to convert date formats into unix time and back.


This is one of the dusty corners of the classad language. The language has a separate type for Absolute and Relative time, called "abstime" and "reltime". You can create an absTime from a string using only one (sadly, united-states centric) format: YYYY-MM-DDTHH:MM" where T is a literal. So, in classads, could create an attribute with an absTime value like this:

cincoDeMayo = abstime("2020-05-05T10:30")

But, what you want is not the absTime type, which doesn't have many operations on it, but the more common Unix epoch format, seconds since Jan 1, 1970, or in this case (in my time zone), 1588692600. To do this in classads, you need to convert the absttime to an integer with a cast. So, try something like

CincoDeUnix = int(abstime("2020-05-05T10:30"))