From a5f1413789b3970a5424f825775089078c6ef90e Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 12 Dec 2008 18:20:45 +0000 Subject: Add strftime [SVN r50249] --- .../compare_trees/compare_trees.vcproj | 197 +++++++++++++++++++++ tools/release/release-mgt-msvc/msvc.sln | 26 +++ .../release-mgt-msvc/strftime/strftime.vcproj | 193 ++++++++++++++++++++ tools/release/strftime.cpp | 66 +++++++ 4 files changed, 482 insertions(+) create mode 100644 tools/release/release-mgt-msvc/compare_trees/compare_trees.vcproj create mode 100644 tools/release/release-mgt-msvc/msvc.sln create mode 100644 tools/release/release-mgt-msvc/strftime/strftime.vcproj create mode 100644 tools/release/strftime.cpp diff --git a/tools/release/release-mgt-msvc/compare_trees/compare_trees.vcproj b/tools/release/release-mgt-msvc/compare_trees/compare_trees.vcproj new file mode 100644 index 0000000000..f52093006f --- /dev/null +++ b/tools/release/release-mgt-msvc/compare_trees/compare_trees.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/release/release-mgt-msvc/msvc.sln b/tools/release/release-mgt-msvc/msvc.sln new file mode 100644 index 0000000000..ca70e06f63 --- /dev/null +++ b/tools/release/release-mgt-msvc/msvc.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compare_trees", "compare_trees\compare_trees.vcproj", "{7E6AD5ED-4168-4613-A342-0217AA82DEC1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strftime", "strftime\strftime.vcproj", "{4A82F955-7630-4B79-9C50-E45F27E28BA8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7E6AD5ED-4168-4613-A342-0217AA82DEC1}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E6AD5ED-4168-4613-A342-0217AA82DEC1}.Debug|Win32.Build.0 = Debug|Win32 + {7E6AD5ED-4168-4613-A342-0217AA82DEC1}.Release|Win32.ActiveCfg = Release|Win32 + {7E6AD5ED-4168-4613-A342-0217AA82DEC1}.Release|Win32.Build.0 = Release|Win32 + {4A82F955-7630-4B79-9C50-E45F27E28BA8}.Debug|Win32.ActiveCfg = Debug|Win32 + {4A82F955-7630-4B79-9C50-E45F27E28BA8}.Debug|Win32.Build.0 = Debug|Win32 + {4A82F955-7630-4B79-9C50-E45F27E28BA8}.Release|Win32.ActiveCfg = Release|Win32 + {4A82F955-7630-4B79-9C50-E45F27E28BA8}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/release/release-mgt-msvc/strftime/strftime.vcproj b/tools/release/release-mgt-msvc/strftime/strftime.vcproj new file mode 100644 index 0000000000..4b8e9ab866 --- /dev/null +++ b/tools/release/release-mgt-msvc/strftime/strftime.vcproj @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/release/strftime.cpp b/tools/release/strftime.cpp new file mode 100644 index 0000000000..4cb2fa0042 --- /dev/null +++ b/tools/release/strftime.cpp @@ -0,0 +1,66 @@ +// Command line utility to output the date under control of a format string + +// Copyright 2008 Beman Dawes + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char * argv[]) +{ + if (argc != 2 ) + { + cerr << + "Invoke: strftime format\n" + "Example: strftime \"The date is %Y?%m?%d in ISO format\"" + "The format codes are:\n" + " %a Abbreviated weekday name\n" + " %A Full weekday name\n" + " %b Abbreviated month name\n" + " %B Full month name\n" + " %c Date and time representation appropriate for locale\n" + " %d Day of month as decimal number (01 – 31)\n" + " %H Hour in 24-hour format (00 – 23)\n" + " %I Hour in 12-hour format (01 – 12)\n" + " %j Day of year as decimal number (001 – 366)\n" + " %m Month as decimal number (01 – 12)\n" + " %M Minute as decimal number (00 – 59)\n" + " %p Current locale's A.M./P.M. indicator for 12-hour clock\n" + " %S Second as decimal number (00 – 59)\n" + " %U Week of year as decimal number, with Sunday as first day of week (00 – 53)\n" + " %w Weekday as decimal number (0 – 6; Sunday is 0)\n" + " %W Week of year as decimal number, with Monday as first day of week (00 – 53)\n" + " %x Date representation for current locale\n" + " %X Time representation for current locale\n" + " %y Year without century, as decimal number (00 – 99)\n" + " %Y Year with century, as decimal number\n" + " %z, %Z Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown\n" + " %% Percent sign\n" + ; + return 1; + } + + string format = argv[1]; + time_t t = time(0); + tm * tod = localtime(&t); + if (!tod) + { + cerr << "error: localtime function failed\n"; + return 1; + } + char* s = new char [format.size() + 256]; + if (strftime( s, format.size() + 256, format.c_str(), tod ) == 0 ) + { + cerr << "error: buffer overflow\n"; + return 1; + } + return 0; +} -- cgit v1.2.1