2014-05-16 18:51:01 +08:00
|
|
|
//===-- MIUtilDateTimeStd.cpp -----------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//++
|
2014-11-18 02:06:21 +08:00
|
|
|
// File: MIUtilDateTimeStd.cpp
|
2014-05-16 18:51:01 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Overview: CMIUtilDateTimeStd implementation.
|
2014-05-16 18:51:01 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Environment: Compilers: Visual C++ 12.
|
|
|
|
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
|
|
|
|
// Libraries: See MIReadmetxt.
|
2014-05-16 18:51:01 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Copyright: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
|
|
|
|
|
|
|
// In-house headers:
|
|
|
|
#include "MIUtilDateTimeStd.h"
|
|
|
|
#include "MICmnResources.h"
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMIUtilDateTimeStd constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilDateTimeStd::CMIUtilDateTimeStd(void)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMIUtilDateTimeStd destructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilDateTimeStd::~CMIUtilDateTimeStd(void)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Retrieve system local current date. Format is MM/DD/YYYY.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: CMIUtilString - Text description.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilString
|
|
|
|
CMIUtilDateTimeStd::GetDate(void)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilString strDate(MIRSRC(IDS_WORD_INVALIDBRKTS));
|
2014-08-09 00:47:42 +08:00
|
|
|
|
2014-11-18 02:06:21 +08:00
|
|
|
std::time(&m_rawTime);
|
|
|
|
const std::tm *pTi = std::localtime(&m_rawTime);
|
|
|
|
if (std::strftime(&m_pScratch[0], sizeof(m_pScratch), "%d/%m/%y", pTi) > 0)
|
|
|
|
strDate = m_pScratch;
|
|
|
|
|
|
|
|
return strDate;
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Retrieve system local current time. Format is HH:MM:SS 24 hour clock.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: CMIUtilString - Text description.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilString
|
|
|
|
CMIUtilDateTimeStd::GetTime(void)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
std::time(&m_rawTime);
|
|
|
|
const std::tm *pTi = std::localtime(&m_rawTime);
|
|
|
|
const CMIUtilString seconds(CMIUtilString::Format("%d", pTi->tm_sec));
|
|
|
|
const CMIUtilString zero((seconds.length() == 1) ? "0" : "");
|
|
|
|
const CMIUtilString strTime(CMIUtilString::Format("%d:%d:%s%s", pTi->tm_hour, pTi->tm_min, zero.c_str(), seconds.c_str()));
|
2014-08-09 00:47:42 +08:00
|
|
|
|
2014-11-18 02:06:21 +08:00
|
|
|
return strTime;
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|