Search local states by time

Thanks @fabrice and @aojjazz for your reply. I will re-design my smart contract to avoid this problem.