47 std::cout <<
"Usage: " << g_progname <<
" [-opt] <time>" << std::endl;
48 std::cout <<
"Where -opt is one or more of:" << std::endl;
49 std::cout <<
" --dec display the result in decimal" << std::endl;
50 std::cout <<
" --dos convert a Unix time to a DOS time (default)" << std::endl;
51 std::cout <<
" --help display this help screen" << std::endl;
52 std::cout <<
" --hex display the result in hexadecimal" << std::endl;
53 std::cout <<
" --unix convert a DOS time to a Unix time" << std::endl;
54 std::cout <<
" --version print the library version and exit" << std::endl;
55 std::cout << std::endl;
56 std::cout <<
"Examples:" << std::endl;
57 std::cout <<
" to convert a Unix time to a DOS time:" << std::endl;
58 std::cout <<
" " << g_progname <<
" 956794294" << std::endl;
59 std::cout <<
" to convert a DOS time to a Unix time:" << std::endl;
60 std::cout <<
" " << g_progname <<
" --unix 681216369" << std::endl;
61 std::cout << std::endl;
62 std::cout <<
"Output:" << std::endl;
63 std::cout <<
"<time entered on command line> <converted time> <date (YYYY/MM/DD)> <time (HH:MM:SS)>" << std::endl;
64 std::cout <<
" Note: <converted time> shows -1 if an error occurs" << std::endl;
79 int main(
int argc,
char *argv[])
96 for(
int i(1); i < argc; ++i)
100 if(strcmp(argv[i],
"--help") == 0
101 || strcmp(argv[i],
"-h") == 0)
105 if(strcmp(argv[i],
"--version") == 0)
112 if(strcmp(argv[i],
"--dec") == 0)
114 std::cout << std::dec;
116 else if(strcmp(argv[i],
"--dos") == 0)
118 mode = time_mode_t::DOS;
120 else if(strcmp(argv[i],
"--hex") == 0)
122 std::cout << std::hex;
124 else if(strcmp(argv[i],
"--unix") == 0)
126 mode = time_mode_t::UNIX;
132 int64_t
const t(atoll(argv[i]));
138 case time_mode_t::DOS:
143 case time_mode_t::UNIX:
150 struct tm *dtm(gmtime(&dt));
158 strftime(buf,
sizeof(buf),
"%Y/%m/%d %T", dtm);
161 std::cout << t <<
" " << r <<
" " << buf << std::endl;
Define a type to manage date and time in MS-DOS format.
std::time_t getUnixTimestamp() const
Retrieve the DOSDateTime as a Unix timestamp.
dosdatetime_t getDOSDateTime() const
Retrieve the DOSDateTime value as is.
void setUnixTimestamp(std::time_t unix_timestamp)
Set the DOSDateTime value from a Unix timestamp.
zipios configuration header.
#define ZIPIOS_VERSION_STRING
void setDOSDateTime(dosdatetime_t datetime)
Set the DOSDateTime value as is.