michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* A test program for PR_FormatTime and PR_FormatTimeUSEnglish */ michael@0: michael@0: #include "prtime.h" michael@0: michael@0: #include michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: char buffer[256]; michael@0: char small_buffer[8]; michael@0: PRTime now; michael@0: PRExplodedTime tod; michael@0: michael@0: now = PR_Now(); michael@0: PR_ExplodeTime(now, PR_LocalTimeParameters, &tod); michael@0: michael@0: if (PR_FormatTime(buffer, sizeof(buffer), michael@0: "%a %b %d %H:%M:%S %Z %Y", &tod) != 0) { michael@0: printf("%s\n", buffer); michael@0: } else { michael@0: fprintf(stderr, "PR_FormatTime(buffer) failed\n"); michael@0: return 1; michael@0: } michael@0: michael@0: small_buffer[0] = '?'; michael@0: if (PR_FormatTime(small_buffer, sizeof(small_buffer), michael@0: "%a %b %d %H:%M:%S %Z %Y", &tod) == 0) { michael@0: if (small_buffer[0] != '\0') { michael@0: fprintf(stderr, "PR_FormatTime(small_buffer) did not output " michael@0: "an empty string on failure\n"); michael@0: return 1; michael@0: } michael@0: printf("%s\n", small_buffer); michael@0: } else { michael@0: fprintf(stderr, "PR_FormatTime(small_buffer) succeeded " michael@0: "unexpectedly\n"); michael@0: return 1; michael@0: } michael@0: michael@0: (void)PR_FormatTimeUSEnglish(buffer, sizeof(buffer), michael@0: "%a %b %d %H:%M:%S %Z %Y", &tod); michael@0: printf("%s\n", buffer); michael@0: michael@0: return 0; michael@0: }