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]));
137 case time_mode_t::DOS:
141 case time_mode_t::UNIX:
147 struct tm *dtm(localtime(&dt));
155 strftime(buf,
sizeof(buf),
"%Y/%m/%d %T", dtm);
158 std::cout << t <<
" " << r <<
" " << buf << std::endl;
dostime_t unix2dostime(time_t unix_time)
Convert a Unix date to a DOS date.
time_t dos2unixtime(dostime_t dostime)
Convert a DOS time to a Unix time.
zipios configuration header.
Definitions for the MS-DOS to Unix time conversions.
int main(int argc, char *argv[])
#define ZIPIOS_VERSION_STRING