REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.06 KB
Close
/opt/alt/alt-nodejs19/root/usr/share/doc/alt-nodejs19-libicu-devel/samples/datefmt/main.cpp
Text
Base64
/************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html ************************************************************************* ************************************************************************* * 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" using namespace icu; /** * 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 const 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 const 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; }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 8
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
answers
DIR
-
drwxr-xr-x
2024-03-03 22:41:03
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
datefmt.sln
1.25 KB
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
datefmt.vcxproj
7.87 KB
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
datefmt.vcxproj.filters
967 B
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
main.cpp
3.06 KB
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Makefile
590 B
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
README.TXT
3.55 KB
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
util.cpp
2.24 KB
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
util.h
879 B
lrw-r--r--
2022-10-19 00:53:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).