1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* A test program for PR_FormatTime and PR_FormatTimeUSEnglish */
12 int main(int argc
, char **argv
)
20 PR_ExplodeTime(now
, PR_LocalTimeParameters
, &tod
);
22 if (PR_FormatTime(buffer
, sizeof(buffer
),
23 "%a %b %d %H:%M:%S %Z %Y", &tod
) != 0) {
24 printf("%s\n", buffer
);
26 fprintf(stderr
, "PR_FormatTime(buffer) failed\n");
30 small_buffer
[0] = '?';
31 if (PR_FormatTime(small_buffer
, sizeof(small_buffer
),
32 "%a %b %d %H:%M:%S %Z %Y", &tod
) == 0) {
33 if (small_buffer
[0] != '\0') {
34 fprintf(stderr
, "PR_FormatTime(small_buffer) did not output "
35 "an empty string on failure\n");
38 printf("%s\n", small_buffer
);
40 fprintf(stderr
, "PR_FormatTime(small_buffer) succeeded "
45 (void)PR_FormatTimeUSEnglish(buffer
, sizeof(buffer
),
46 "%a %b %d %H:%M:%S %Z %Y", &tod
);
47 printf("%s\n", buffer
);