26#if defined (HAVE_CONFIG_H)
37#if defined (OCTAVE_USE_WINDOWS_API)
58 : m_ot_unix_time (static_cast<OCTAVE_TIME_T> (
d)), m_ot_usec (0)
61 m_ot_usec =
static_cast<int> (std::modf (
d, &ip) * 1e6);
65 : m_ot_unix_time (), m_ot_usec ()
71 t.tm_hour = tm.
hour ();
72 t.tm_mday = tm.
mday ();
74 t.tm_year = tm.
year ();
75 t.tm_wday = tm.
wday ();
76 t.tm_yday = tm.
yday ();
77 t.tm_isdst = tm.
isdst ();
79#if defined (HAVE_TM_GMTOFF)
80 t.tm_gmtoff = tm.
gmtoff ();
83#if defined (HAVE_STRUCT_TM_TM_ZONE)
84 std::string s = tm.
zone ();
85 char *ps =
strsave (s.c_str ());
91#if defined (HAVE_STRUCT_TM_TM_ZONE)
95 m_ot_usec = tm.
usec ();
109 os << ot.m_ot_unix_time <<
'.'
110 << std::setw (6) << std::setfill (
'0') << ot.m_ot_usec;
120 m_ot_unix_time = ot_unix_time;
136#define DEFINE_SET_FIELD_FCN(type, f, lo, hi) \
138 base_tm::f (type v) \
145#define DEFINE_SET_INT_FIELD_FCN(f, lo, hi) \
146 DEFINE_SET_FIELD_FCN (int, f, lo, hi)
155 std::numeric_limitd<
int>::
max ())
168#if ! defined STRFTIME_BUF_INITIAL_SIZE
169# define STRFTIME_BUF_INITIAL_SIZE 128
191#if defined (HAVE_TM_GMTOFF)
195#if defined (HAVE_STRUCT_TM_TM_ZONE)
200 const char *fmt_str = fmt.c_str ();
204 std::size_t chars_written = 0;
206 while (chars_written == 0)
209 buf =
new char [bufsize];
218#if defined (HAVE_STRUCT_TM_TM_ZONE)
236 struct ::tm *t =
static_cast<struct ::tm *
> (p);
248#if defined (HAVE_TM_GMTOFF)
250#elif defined (OCTAVE_USE_WINDOWS_API)
251 TIME_ZONE_INFORMATION tzi;
253 GetTimeZoneInformationForYear (
m_year,
nullptr, &tzi);
256 m_gmtoff = -60 * (tzi.Bias + tzi.DaylightBias);
258 m_gmtoff = -60 * (tzi.Bias + tzi.StandardBias);
261#if defined (HAVE_STRUCT_TM_TM_ZONE)
264#elif defined (OCTAVE_USE_WINDOWS_API)
266 m_zone = sys::u8_from_wstring (tzi.DaylightName);
268 m_zone = sys::u8_from_wstring (tzi.StandardName);
269#elif defined (HAVE_TZNAME)
270 if (t->tm_isdst == 0 || t->tm_isdst == 1)
271 m_zone = tzname[t->tm_isdst];
276localtime::init (
const time& ot)
286gmtime::init (
const time& ot)
296strptime::init (
const std::string& str,
const std::string& fmt)
305 t.tm_year = std::numeric_limits<int>::min ();
310#if defined (HAVE_TM_GMTOFF)
314#if defined (HAVE_STRUCT_TM_TM_ZONE)
319 const char *p = str.c_str ();
325 if (t.tm_mday != 0 && t.tm_mon >= 0
326 && t.tm_year != std::numeric_limits<int>::min ())
335 if (t.tm_year == std::numeric_limits<int>::min ())
339 m_nchars = q - p + 1;
345#if defined (HAVE_STRUCT_TM_TM_ZONE)
353 time_t usr_sec, sys_sec;
362 time_t usr_sec, sys_sec;
363 long usr_usec, sys_usec;
366 &sys_usec, &m_maxrss, &m_ixrss,
367 &m_idrss, &m_isrss, &m_minflt,
368 &m_majflt, &m_nswap, &m_inblock,
369 &m_oublock, &m_msgsnd, &m_msgrcv,
370 &m_nsignals, &m_nvcsw, &m_nivcsw);
372 m_cpu =
cpu_time (usr_sec, sys_sec, usr_usec, sys_usec);
377#if defined (OCTAVE_USE_WINDOWS_API)
378 FILETIME curr_file_time;
379 GetSystemTimeAsFileTime (&curr_file_time);
381 = (
static_cast<OCTAVE_TIME_T
> (curr_file_time.dwHighDateTime)) << 32
382 | (
static_cast<OCTAVE_TIME_T
> (curr_file_time.dwLowDateTime));
388 m_time = ot_unix_time;
394#if defined (OCTAVE_USE_WINDOWS_API)
395 std::wstring wfull_name = sys::u8_to_wstring (filename);
396 WIN32_FILE_ATTRIBUTE_DATA file_attributes;
398 if (! GetFileAttributesExW (wfull_name.c_str (), GetFileExInfoStandard,
405 FILETIME last_write_time = file_attributes.ftLastWriteTime;
408 = (
static_cast<OCTAVE_TIME_T
> (last_write_time.dwHighDateTime)) << 32
409 | (
static_cast<OCTAVE_TIME_T
> (last_write_time.dwLowDateTime));
412 m_time = fs.
mtime ().unix_time ();
416OCTAVE_END_NAMESPACE(sys)
417OCTAVE_END_NAMESPACE(octave)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
std::string asctime() const
std::string strftime(const std::string &fmt) const
std::string ctime() const
OCTAVE_TIME_T unix_time() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
char * strsave(const char *s)
#define DEFINE_SET_INT_FIELD_FCN(f, lo, hi)
#define STRFTIME_BUF_INITIAL_SIZE
std::ostream & operator<<(std::ostream &os, const time &ot)
#define DEFINE_SET_FIELD_FCN(type, f, lo, hi)
size_t octave_strftime_wrapper(char *buf, size_t len, const char *fmt, const struct tm *t)
char * octave_strptime_wrapper(const char *p, const char *fmt, struct tm *t)
int octave_cpu_time(time_t *usr_sec, time_t *sys_sec, long *usr_usec, long *sys_usec)
int octave_gettimeofday_wrapper(time_t *sec, long *usec)
time_t octave_mktime_wrapper(struct tm *tp)
int octave_getrusage_wrapper(time_t *usr_sec, time_t *sys_sec, long *usr_usec, long *sys_usec, long *maxrss, long *ixrss, long *idrss, long *isrss, long *minflt, long *majflt, long *nswap, long *inblock, long *oublock, long *msgsnd, long *msgrcv, long *nsignals, long *nvcsw, long *nivcsw)