Is there a function to santize a date vector?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I was wondering if there's a function to sanitize a date vector (or add a time in seconds to a date vector). For example, if I want to find the date and time 1 millions seconds in the future:
present = datevec(now);
look_ahead = 1e6; % fast forward 1 million seconds
% the date vector for the future
future = present;
future(end) = future(end) + look_ahead;
% print the date one million seconds in the future
future_str = datestr(future) % not what's intended
% Work around it by converting look_ahead to a time stamp.
% This work around is "clunky", loses precision, and is not guaranteed to be correct
look_ahead_stamp = look_ahead / (24*60*60); % if only all days had the same number of seconds
future_str = datestr(datenum(present) + look_ahead_stamp)
% Ideal Solution:
future = SantizeDateVec(future); % does this function exist?
datestr(future)
Any suggestions on the above would be appreciated,
Cheers, Andrew
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!