I’ve found another expression which works for me:
L = thisLayer;
Src = L.source;
SrcDur = Src.duration;
LDur = L.outPoint-L.inPoint;
SrcInDur = framesToTime(28); //the duration of the in animation
SrcOutDur = framesToTime(34); //the duration of the out animation
SrcLoopDur = SrcDur-SrcInDur-SrcOutDur;
if(time < L.inPoint+ SrcInDur) {
tSampleT = time-L.inPoint;
} else if(time > L.outPoint-SrcOutDur) {
LOutElapsed = time - (L.outPoint-SrcOutDur);
tSampleT = SrcDur-SrcOutDur + LOutElapsed;
} else {
tSampleT = SrcInDur+Src.frameDuration;
}