Re: JMP Time Formatting 12 v 24 hr control - Status changed to: DeliveredStarting in JMP 16, you can now define custom date, time, and datetime format patterns in JSL or interactively.
More information at Formatting Custom Dates
Re: JMP Time Formatting 12 v 24 hr controlIf updating the format function, a corresponding parse function using the same set of format characters would save a bunch of time. This function might be ideal.
parse_datetime (
"File sent 4:56 AM on 3-2-2019, 100% complete.",
"*sent %%h:%%m %%AM on %%m-%%d-%%y*",
prepend = "%%",
wild = "*"
)
Re: JMP Time Formatting 12 v 24 hr controlI've given the timestamp subject much thought as it impacts global 24 hour operations. Because of differing local conventions (month first or day first), use of digits for day and month becomes ambiguous! Therefore I strongly prefer the use of Alpha Mon for month. Adding this thought to the nice time formatting suggestions above, I would like to see:
//What user wants: "12Sep2018 17:12:46" //For example: This preferred global 24 hour format timestamp is available as "PI Time format" in OSISoft's leading PI historian.
JMP Pro 14.1 comes pretty close now with ddMonyyyy:h:m:s, but the :h is very hard to see and interpret, and a colon before a time is just "weird". Either the capital H or dbl-lower-case hh would be more clear.
Re: JMP Time Formatting 12 v 24 hr controlYes I agree, if they will update the format() function it would be nice for them to go all out and make it as robust as possible.
Some useful links on time formatting:
https://en.wikipedia.org/wiki/ISO_8601
https://www.w3.org/TR/NOTE-datetime
Re: JMP Time Formatting 12 v 24 hr controlI propose taking this a step further and allowing the user to specify any format. The default behavior of format would be something like this:
Names default to here(1);
time = 3619617166;
pad = function( {x}, if(x < 10, "0" || char( x ), char( x )));
formatdatetime = function({time, pattern, prepend=""},
char(substitute(pattern,
prepend || "H", pad(hour(time, 24)),
prepend || "h", pad(hour(time, 12)),
prepend || "M", pad(minute(time)),
prepend || "S", pad(second(time)),
prepend || "m", pad(month(time)),
prepend || "d", pad(day(time)),
prepend || "y", char(year(time)),
prepend || "AP", char(if(hour(time)==24, "AM", if(hour(time, 24)>11,"PM","AM"))),
// the rest of the formatting options..Month name,
// short month name, hours without padding, etc
))
);
formatdatetime(time, "m/d/y h:M:S AP");
// 09/12/2018 05:12:46 PM
formatdatetime(time, "ymd_HMS");
// 20180912_171246
formatdatetime(time, "hour = %h, minute = %M", "%")
// hour = 05, minute = 12JMP Time Formatting 12 v 24 hr controlPlease allow users to select the time format (12 vs 24 hour) directly.
time = today(); //3619617166
formattedTime = format(time, "m/d/y h:m:s");
print(formattedTime); //"09/12/2018 5:12:46 PM"
//What user wants: "09/12/2018 17:12:46"
Options:
m/d/y/ H:m:s (capital H to denote 24 hours -- common in other languages)
format(time, "m/d/y h:m:s", 24) - allow it to be specified in the format function, similar to Hour() function
There's some cryptic notes in the Scripting Guide that suggest the format() function chooses 12hr or 24hrs based on the computer settings, which means scripts would end up breaking on some users computers and would be difficult troubleshoot.
Mass Customization