To avoid leading spaces on the fractional part you need to provide a '0' between the '%' and the width digit. For example,
Tim Mooney wrote:
By the way, you example problem is treated in Ned Arnold's devTimeOfDay.c.
I snuck a copy of this into the synApps std module, if you're interested.
These old timestamp conversion device supports are no longer needed, and should be eliminated - since R3.14.5 there has been a soft stringin device support included with Base called devTimestampSI.c whose INST_IO parm string is a format string for epicsTimeToStrftime() which extends the strftime() formatting to include fractional seconds.
The time value that this device support converts is the timestamp of the stringin record itself, but by pointing its .TSEL field to another record's .TIME field it can be made to convert arbitrary timestamps by reading them from that other record. If the time you want to convert isn't in any record's timestamp yet, you can make it one using a subroutine record whose subroutine sets its own timestamp by converting it from whatever format you do have (the sub record will need to have its .TSE field set to -2 to stop it from being overwritten by the record support afterwards).
Here are a couple of examples, untested.
# timeString gives the timestamp from timeMe
record(bi, "timeMe") {
field(SCAN, "I/O Intr")
field(FLNK, "timeString")
...
}
record(stringin, "timeString") {
field(TSEL, "timeMe.TIME")
field(DTYP, "Soft Timestamp")
field(INP, "@%Y-%m-%d %H:%M:%S.%9f")
}
# Offset timestamp
record(sub, "drWho") {
field(TSE, "-2")
field(SNAM, "timeTravel")
field(INPA, "10")
}
record(stringin, "timeString") {
field(TSEL, "delayedTime.TIME")
field(DTYP, "Soft Timestamp")
field(INP, "@%Y-%m-%d %H:%M:%S.%9f")
}
static long timeTravel(subRecord *precord)
{
epicsTimeGetCurrent(&precord->time);
epicsTimeAddSeconds(&precord->time, precord->a)
return 0;
}
If somebody wants to test the above and post any corrections this message can act as an example to future questioners on the topic.