summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2007-01-28 10:26:59 -0800
committerNathan Binkert <binkertn@umich.edu>2007-01-28 10:26:59 -0800
commit37795b104d93a48b319074fbef770d88820d554a (patch)
treeadb7bdddc656a667ecb84609caebd2a86defb2ee /src/sim
parentf9a341f8e7871135e52d208c65185c96c1e51de5 (diff)
downloadgem5-37795b104d93a48b319074fbef770d88820d554a.tar.xz
Stick the conversion of python to unix time with all of
the other param code so that other functions can use it as well. --HG-- extra : convert_revision : a8becdeadc70af0b64bff5b0770788dfba6e1857
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/param.cc24
-rw-r--r--src/sim/param.hh1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/sim/param.cc b/src/sim/param.cc
index b1c50946b..5cc69b161 100644
--- a/src/sim/param.cc
+++ b/src/sim/param.cc
@@ -777,3 +777,27 @@ ParamContext::describeAllContexts(ostream &os)
os << endl;
}
}
+
+void
+parseTime(const std::vector<int> &time, struct tm *tm)
+{
+ memset(tm, 0, sizeof(struct tm));
+
+ // UNIX is years since 1900
+ tm->tm_year = time[0] - 1900;
+
+ // Python starts at 1, UNIX starts at 0
+ tm->tm_mon = time[1] - 1;
+ tm->tm_mday = time[2];
+ tm->tm_hour = time[3];
+ tm->tm_min = time[4];
+ tm->tm_sec = time[5];
+
+ // Python has 0 as Monday, UNIX is 0 as sunday
+ tm->tm_wday = time[6] + 1;
+ if (tm->tm_wday > 6)
+ tm->tm_wday -= 7;
+
+ // Python starts at 1, Unix starts at 0
+ tm->tm_yday = time[7] - 1;
+}
diff --git a/src/sim/param.hh b/src/sim/param.hh
index 2aa0456da..8a4670e27 100644
--- a/src/sim/param.hh
+++ b/src/sim/param.hh
@@ -781,4 +781,5 @@ SimObjectVectorParam<OBJ_CLASS *>::showType(std::ostream &os) const \
template <class T> bool parseParam(const std::string &str, T &data);
template <class T> void showParam(std::ostream &os, const T &data);
+void parseTime(const std::vector<int> &time, struct tm *tm);
#endif // _SIM_PARAM_HH_