utils_time.h File Reference

Time and datetime related functions in CCGL. More...

#include "basic.h"

Go to the source code of this file.

Classes

struct  ccgl::utils_time::DateTime
 A type representing the combination of date and time. More...
 

Namespaces

namespace  ccgl
 Common Cross-platform Geographic Library (CCGL)
 
namespace  ccgl::utils_time
 Time related functions.
 

Functions

double ccgl::utils_time::TimeCounting ()
 Precisely and cross-platform time counting function.
 
bool ccgl::utils_time::IsLeapYear (const int yr)
 Check the given year is a leap year or not. More...
 
string ccgl::utils_time::ConvertToString (const time_t date, bool utc_time=true)
 Convert date time to string as the format of "YYYY-MM-DD". More...
 
string ccgl::utils_time::ConvertToString2 (const time_t date, bool utc_time=true)
 Convert date time to string as the format of "YYYY-MM-DD HH". More...
 
string ccgl::utils_time::ConvertToString3 (const time_t date, const bool utc_time)
 format: 2022_11_17_092000 More...
 
time_t ccgl::utils_time::ConvertToTime (const string &str_date, string const &format, bool include_hour, bool utc_time=true)
 Convert string to date time, string format could be %4d%2d%2d or d-d-d. More...
 
time_t ccgl::utils_time::ConvertYMDToTime (int &year, int &month, int &day, bool utc_time=true)
 Convert integer year, month, and day to date time. More...
 
int ccgl::utils_time::GetDateInfoFromTimet (time_t t, int *year, int *month, int *day, bool utc_time=true)
 Get date information from time_t variable. More...
 
void ccgl::utils_time::LocalTime (time_t date, struct tm *t)
 Get local time. More...
 
void ccgl::utils_time::UTCTime (time_t date, struct tm *t)
 Get UTC:+00:00 time. More...
 
void ccgl::utils_time::GetDateTime (time_t date, struct tm *t, bool utc_time=true)
 Get UTC:+00:00 time. More...
 
int ccgl::utils_time::GetYear (time_t date, bool utc_time=true)
 Get the year. More...
 
int ccgl::utils_time::GetMonth (time_t date, bool utc_time=true)
 Get the month. More...
 
int ccgl::utils_time::GetDay (time_t date, bool utc_time=true)
 Get the day. More...
 
int ccgl::utils_time::DayOfYear (time_t date, bool utc_time=true)
 Get the day of one year, [1, 366].
 
int ccgl::utils_time::DayOfYear (int year, int month, int day)
 Get the day of one year, [1, 366].
 
int ccgl::utils_time::JulianDay (time_t date, bool utc_time=true)
 Get the Julian day from time_t date.
 
int ccgl::utils_time::JulianDay (int year, int month, int day)
 Get the Julian day of one day from year, month, and day. More...
 

Detailed Description

Time and datetime related functions in CCGL.

Remarks
  • 1. 2018-05-01 - lj - Make part of CCGL.
  • 2. 2018-05-23 - lj - Add DateTime struct which combines date and time.
Author
Liangjun Zhu, zlj(at)lreis.ac.cn