diff options
Diffstat (limited to 'Build/source/libs/icu/icu-4.6/samples/datefmt')
12 files changed, 907 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/Makefile b/Build/source/libs/icu/icu-4.6/samples/datefmt/Makefile new file mode 100644 index 00000000000..6b0cb23b7b1 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) 2000-2002 IBM, Inc. and others +# sample code makefile + +# Usage: +# - configure, build, install ICU (make install) +# - make sure "icu-config" (in the ICU installed bin directory) is on +# the path +# - do 'make' in this directory + +# Name of your target +TARGET=datefmt + +# All object files (C or C++) +OBJECTS=main.o util.o + +# Load in standard makefile definitions +include ../defs.mk + +# the actual rules (this is a simple sample) +include ../rules.mk diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/README.TXT b/Build/source/libs/icu/icu-4.6/samples/datefmt/README.TXT new file mode 100644 index 00000000000..3671b15b9a8 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/README.TXT @@ -0,0 +1,104 @@ +Copyright (c) 2002-2010, International Business Machines Corporation and others. All Rights Reserved. + +IMPORTANT: + +This sample was originally intended as an exercise for the ICU Workshop (September 2000). +The code currently provided in the solution file is the answer to the exercises, each step can still be found in the 'answers' subdirectory. + + + +** Workshop homepage is: + http://www.icu-project.org/docs/workshop_2000/agenda.html + + #Date/Time/Number Formatting Support + 9:30am - 10:30am + Alan Liu + + Topics: + 1. What is the date/time support in ICU? + 2. What is the timezone support in ICU? + 3. What kind of formatting and parsing support is available in ICU, i.e. + NumberFormat, DateFormat, MessageFormat? + + +INSTRUCTIONS +------------ + +This exercise was first developed and tested on ICU release 1.6.0, Win32, +Microsoft Visual C++ 6.0. It should work on other ICU releases and +other platforms as well. + + MSVC: + Open the file "datefmt.sln" in Microsoft Visual C++. + + Unix: + - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU' + - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in + this directory. + - You may use 'make check' to invoke this sample. + +PROBLEMS +-------- + +Problem 0: + + Set up the program, build it, and run it. To start with, the + program prints out a list of languages. + +Problem 1: Basic Date Formatting (Easy) + + Create a calendar, and use it to get the UDate for June 4, 1999, + 0:00 GMT (or any date of your choosing). You will have to create a + TimeZone (use the createZone() function already defined in main.cpp) + and a Calendar object, and make the calendar use the time zone. + + Once you have the UDate, create a DateFormat object in each of the + languages in the LANGUAGE array, and display the date in that + language. Use the DateFormat::createDateInstance() method to create + the date formatter. + +Problem 2: Date Formatting, Specific Time Zone (Medium) + + To really localize a time display, one can also specify the time + zone in which the time should be displayed. For each language, + also create different time zones from the TIMEZONE list. + + To format a date with a specific calendar and zone, you must deal with + three objects: a DateFormat, a Calendar, and a TimeZone. Each object + must be linked to another in correct sequence: The Calendar must use + the TimeZone, and the DateFormat must use the Calendar. + + DateFormat =uses=> Calendar =uses=> TimeZone + + Use either setFoo() or adoptFoo() methods, depending on where you + want to have ownership. + + NOTE: It's not always desirable to change the time to a local time + zone before display. For instance, if some even occurs at 0:00 GMT + on the first of the month, it's probably clearer to just state that. + Stating that it occurs at 5:00 PM PDT on the day before in the + summer, and 4:00 PM PST on the day before in the winter will just + confuse the issue. + + +NOTES +----- + +To see a list of system TimeZone IDs, use the TimeZone::create- +AvailableIDs() methods. Alternatively, look at the file +icu/docs/tz.htm. This has a hyperlinked list of current system zones. + + +ANSWERS +------- + +The exercise includes answers. These are in the "answers" directory, +and are numbered 1, 2, etc. + +If you get stuck and you want to move to the next step, copy the +answers file into the main directory in order to proceed. E.g., +"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" +contains the "main.cpp" file after problem 1. Etc. + + +Have fun! diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_0.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_0.cpp new file mode 100644 index 00000000000..2f4dad212aa --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_0.cpp @@ -0,0 +1,66 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include "unicode/uclean.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Display the formatted date string + printf("Date (%s)\n", LANGUAGE[i]); + } + + printf("Exiting successfully\n"); + u_cleanup(); + return 0; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_1.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_1.cpp new file mode 100644 index 00000000000..ad8c99c88a6 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_1.cpp @@ -0,0 +1,64 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Display the formatted date string + printf("Date (%s)\n", LANGUAGE[i]); + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_2.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_2.cpp new file mode 100644 index 00000000000..e677a4fd1b2 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_2.cpp @@ -0,0 +1,87 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE + fmt = DateFormat::createDateInstance(DateFormat::kFull, loc); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s): ", LANGUAGE[i]); + uprintf(escape(str)); + printf("\n\n"); + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_3.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_3.cpp new file mode 100644 index 00000000000..e7776836277 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/answers/main_3.cpp @@ -0,0 +1,96 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE and TIME + fmt = DateFormat::createDateTimeInstance( + DateFormat::kFull, DateFormat::kFull, loc); + + for (int32_t j=0; j<N_TIMEZONE; ++j) { + + cal->adoptTimeZone(createZone(TIMEZONE[j])); + fmt->setCalendar(*cal); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]); + uprintf(escape(str)); + printf("\n\n"); + } + + delete fmt; + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.sln b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.sln new file mode 100644 index 00000000000..f49684c02fa --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datefmt", "datefmt.vcproj", "{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.ActiveCfg = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.Build.0 = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.ActiveCfg = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.Build.0 = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.ActiveCfg = Release|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.Build.0 = Release|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.ActiveCfg = Release|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj new file mode 100644 index 00000000000..991a549ba29 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj @@ -0,0 +1,245 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <TypeLibraryName>.\x86\Debug/datefmt.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <PrecompiledHeaderOutputFile>.\x86\Debug/datefmt.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
+ <ObjectFileName>.\x86\Debug/</ObjectFileName>
+ <ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>.\x86\Debug/datefmt.exe</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>.\x86\Debug/datefmt.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>.\x64\Debug/datefmt.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <PrecompiledHeaderOutputFile>.\x64\Debug/datefmt.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
+ <ObjectFileName>.\x64\Debug/</ObjectFileName>
+ <ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>.\x64\Debug/datefmt.exe</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>.\x64\Debug/datefmt.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <TypeLibraryName>.\x86\Release/datefmt.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <PrecompiledHeaderOutputFile>.\x86\Release/datefmt.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
+ <ObjectFileName>.\x86\Release/</ObjectFileName>
+ <ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>.\x86\Release/datefmt.exe</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>.\x86\Release/datefmt.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>.\x64\Release/datefmt.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <PrecompiledHeaderOutputFile>.\x64\Release/datefmt.pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
+ <ObjectFileName>.\x64\Release/</ObjectFileName>
+ <ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>.\x64\Release/datefmt.exe</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>.\x64\Release/datefmt.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ <ClCompile Include="util.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj.filters b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj.filters new file mode 100644 index 00000000000..80620162520 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/datefmt.vcxproj.filters @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{a5cbb044-7694-4d1d-98c1-bb578ee7f1ea}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{aadf5a92-1812-45ce-90a0-e9db3945d7c5}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{9eff3ddc-6822-4225-81fc-a867b9e592c0}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="util.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/main.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/main.cpp new file mode 100644 index 00000000000..e004f9c1307 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/main.cpp @@ -0,0 +1,96 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE and TIME + fmt = DateFormat::createDateTimeInstance( + DateFormat::kFull, DateFormat::kFull, loc); + + for (int32_t j=0; j<N_TIMEZONE; ++j) { + + cal->adoptTimeZone(createZone(TIMEZONE[j])); + fmt->setCalendar(*cal); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]); + uprintf(escape(str)); + printf("\n\n"); + } + + delete fmt; + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/util.cpp b/Build/source/libs/icu/icu-4.6/samples/datefmt/util.cpp new file mode 100644 index 00000000000..9d122dba039 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/util.cpp @@ -0,0 +1,63 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002,2009, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include <stdio.h> +#include <stdlib.h> + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + static const UnicodeString DIGIT_STRING("0123456789ABCDEF"); + while (digits > 0) { + target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF]; + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += "\""; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { + target += "\\u"; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += "\""; + return target; +} + +// Print the given string to stdout +void uprintf(const UnicodeString &str) { + char *buf = 0; + int32_t len = str.length(); + // int32_t bufLen = str.extract(0, len, buf); // Preflight + /* Preflighting seems to be broken now, so assume 1-1 conversion, + plus some slop. */ + int32_t bufLen = len + 16; + int32_t actualLen; + buf = new char[bufLen + 1]; + actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion + buf[actualLen] = 0; + printf("%s", buf); + delete[] buf; +} diff --git a/Build/source/libs/icu/icu-4.6/samples/datefmt/util.h b/Build/source/libs/icu/icu-4.6/samples/datefmt/util.h new file mode 100644 index 00000000000..2d9c4c724e2 --- /dev/null +++ b/Build/source/libs/icu/icu-4.6/samples/datefmt/util.h @@ -0,0 +1,16 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); |