Time-Series Representation Learning through Dynamic Temporal Reordering and Test-Time Adaptation