annotate src/strftime.c @ 5492:e82f5b7010fe

Merge some stuff in man, fix up Makefile -------------------- ChangeLog entries follow: -------------------- man/ChangeLog addition: 2010-02-19 Ben Wing <ben@xemacs.org> * widget.texi: * widget.texi (Top): * widget.texi (Introduction): * widget.texi (User Interface): * widget.texi (Programming Example): * widget.texi (Setting Up the Buffer): * widget.texi (Basic Types): * widget.texi (link): * widget.texi (url-link): * widget.texi (info-link): * widget.texi (push-button): * widget.texi (editable-field): * widget.texi (text): * widget.texi (menu-choice): * widget.texi (radio-button-choice): * widget.texi (item): * widget.texi (choice-item): * widget.texi (toggle): * widget.texi (checkbox): * widget.texi (checklist): * widget.texi (editable-list): * widget.texi (group): * widget.texi (Sexp Types): * widget.texi (constants): * widget.texi (generic): * widget.texi (atoms): * widget.texi (composite): * widget.texi (Widget Properties): * widget.texi (Defining New Widgets): * widget.texi (Widget Browser): * widget.texi (Widget Minor Mode): * widget.texi (Utilities): * widget.texi (Widget Wishlist): * widget.texi (Widget Internals): * widget.texi (GNU Free Documentation License): * widget.texi (Index): Sync with FSF 23.1.92. 2010-02-19 Ben Wing <ben@xemacs.org> * texinfo/fdl.texi: New file. * texinfo/texinfo.texi: * texinfo/texinfo.texi (Top): * texinfo/texinfo.texi (Copying Conditions): * texinfo/texinfo.texi (Overview): * texinfo/texinfo.texi (Reporting Bugs): * texinfo/texinfo.texi (Using Texinfo): * texinfo/texinfo.texi (Output Formats): * texinfo/texinfo.texi (Info Files): * texinfo/texinfo.texi (Printed Books): * texinfo/texinfo.texi (Formatting Commands): * texinfo/texinfo.texi (Conventions): * texinfo/texinfo.texi (Comments): * texinfo/texinfo.texi (Minimum): * texinfo/texinfo.texi (Six Parts): * texinfo/texinfo.texi (Short Sample): * texinfo/texinfo.texi (History): * texinfo/texinfo.texi (Texinfo Mode): * texinfo/texinfo.texi (Texinfo Mode Overview): * texinfo/texinfo.texi (XEmacs Editing): * texinfo/texinfo.texi (Inserting): * texinfo/texinfo.texi (Showing the Structure): * texinfo/texinfo.texi (Updating Nodes and Menus): * texinfo/texinfo.texi (Updating Commands): * texinfo/texinfo.texi (Updating Requirements): * texinfo/texinfo.texi (Other Updating Commands): * texinfo/texinfo.texi (Info Formatting): * texinfo/texinfo.texi (Printing): * texinfo/texinfo.texi (Texinfo Mode Summary): * texinfo/texinfo.texi (Beginning a File): * texinfo/texinfo.texi (Sample Beginning): * texinfo/texinfo.texi (Texinfo File Header): * texinfo/texinfo.texi (First Line): * texinfo/texinfo.texi (Start of Header): * texinfo/texinfo.texi (setfilename): * texinfo/texinfo.texi (settitle): * texinfo/texinfo.texi (End of Header): * texinfo/texinfo.texi (Document Permissions): * texinfo/texinfo.texi (copying): * texinfo/texinfo.texi (insertcopying): * texinfo/texinfo.texi (Titlepage & Copyright Page): * texinfo/texinfo.texi (titlepage): * texinfo/texinfo.texi (titlefont center sp): * texinfo/texinfo.texi (title subtitle author): * texinfo/texinfo.texi (Copyright): * texinfo/texinfo.texi (end titlepage): * texinfo/texinfo.texi (headings on off): * texinfo/texinfo.texi (Contents): * texinfo/texinfo.texi (The Top Node): * texinfo/texinfo.texi (Top Node Example): * texinfo/texinfo.texi (Master Menu Parts): * texinfo/texinfo.texi (Global Document Commands): * texinfo/texinfo.texi (documentdescription): * texinfo/texinfo.texi (setchapternewpage): * texinfo/texinfo.texi (paragraphindent): * texinfo/texinfo.texi (firstparagraphindent): * texinfo/texinfo.texi (exampleindent): * texinfo/texinfo.texi (Software Copying Permissions): * texinfo/texinfo.texi (Ending a File): * texinfo/texinfo.texi (Printing Indices & Menus): * texinfo/texinfo.texi (File End): * texinfo/texinfo.texi (Structuring): * texinfo/texinfo.texi (Tree Structuring): * texinfo/texinfo.texi (Structuring Command Types): * texinfo/texinfo.texi (makeinfo top): * texinfo/texinfo.texi (chapter): * texinfo/texinfo.texi (unnumbered & appendix): * texinfo/texinfo.texi (majorheading & chapheading): * texinfo/texinfo.texi (section): * texinfo/texinfo.texi (unnumberedsec appendixsec heading): * texinfo/texinfo.texi (subsection): * texinfo/texinfo.texi (unnumberedsubsec appendixsubsec subheading): * texinfo/texinfo.texi (subsubsection): * texinfo/texinfo.texi (Raise/lower sections): * texinfo/texinfo.texi (Nodes): * texinfo/texinfo.texi (Two Paths): * texinfo/texinfo.texi (Node Menu Illustration): * texinfo/texinfo.texi (node): * texinfo/texinfo.texi (Node Names): * texinfo/texinfo.texi (Writing a Node): * texinfo/texinfo.texi (Node Line Tips): * texinfo/texinfo.texi (Node Line Requirements): * texinfo/texinfo.texi (First Node): * texinfo/texinfo.texi (makeinfo top command): * texinfo/texinfo.texi (makeinfo Pointer Creation): * texinfo/texinfo.texi (anchor): * texinfo/texinfo.texi (Menus): * texinfo/texinfo.texi (Menu Location): * texinfo/texinfo.texi (Writing a Menu): * texinfo/texinfo.texi (Menu Parts): * texinfo/texinfo.texi (Less Cluttered Menu Entry): * texinfo/texinfo.texi (Menu Example): * texinfo/texinfo.texi (Other Info Files): * texinfo/texinfo.texi (Cross References): * texinfo/texinfo.texi (References): * texinfo/texinfo.texi (Cross Reference Commands): * texinfo/texinfo.texi (Cross Reference Parts): * texinfo/texinfo.texi (xref): * texinfo/texinfo.texi (Reference Syntax): * texinfo/texinfo.texi (One Argument): * texinfo/texinfo.texi (Two Arguments): * texinfo/texinfo.texi (Three Arguments): * texinfo/texinfo.texi (Four and Five Arguments): * texinfo/texinfo.texi (Top Node Naming): * texinfo/texinfo.texi (ref): * texinfo/texinfo.texi (pxref): * texinfo/texinfo.texi (inforef): * texinfo/texinfo.texi (uref): * texinfo/texinfo.texi (cite): * texinfo/texinfo.texi (Marking Text): * texinfo/texinfo.texi (Indicating): * texinfo/texinfo.texi (Useful Highlighting): * texinfo/texinfo.texi (code): * texinfo/texinfo.texi (kbd): * texinfo/texinfo.texi (key): * texinfo/texinfo.texi (samp): * texinfo/texinfo.texi (verb): * texinfo/texinfo.texi (var): * texinfo/texinfo.texi (env): * texinfo/texinfo.texi (file): * texinfo/texinfo.texi (command): * texinfo/texinfo.texi (option): * texinfo/texinfo.texi (dfn): * texinfo/texinfo.texi (abbr): * texinfo/texinfo.texi (acronym): * texinfo/texinfo.texi (indicateurl): * texinfo/texinfo.texi (email): * texinfo/texinfo.texi (Emphasis): * texinfo/texinfo.texi (emph & strong): * texinfo/texinfo.texi (Smallcaps): * texinfo/texinfo.texi (Fonts): * texinfo/texinfo.texi (Quotations and Examples): * texinfo/texinfo.texi (Block Enclosing Commands): * texinfo/texinfo.texi (quotation): * texinfo/texinfo.texi (example): * texinfo/texinfo.texi (verbatim): * texinfo/texinfo.texi (verbatiminclude): * texinfo/texinfo.texi (lisp): * texinfo/texinfo.texi (small): * texinfo/texinfo.texi (display): * texinfo/texinfo.texi (format): * texinfo/texinfo.texi (exdent): * texinfo/texinfo.texi (flushleft & flushright): * texinfo/texinfo.texi (noindent): * texinfo/texinfo.texi (indent): * texinfo/texinfo.texi (cartouche): * texinfo/texinfo.texi (Lists and Tables): * texinfo/texinfo.texi (Introducing Lists): * texinfo/texinfo.texi (itemize): * texinfo/texinfo.texi (enumerate): * texinfo/texinfo.texi (Two-column Tables): * texinfo/texinfo.texi (table): * texinfo/texinfo.texi (ftable vtable): * texinfo/texinfo.texi (itemx): * texinfo/texinfo.texi (Multi-column Tables): * texinfo/texinfo.texi (Multitable Column Widths): * texinfo/texinfo.texi (Multitable Rows): * texinfo/texinfo.texi (Special Displays): * texinfo/texinfo.texi (Floats): * texinfo/texinfo.texi (float): * texinfo/texinfo.texi (caption shortcaption): * texinfo/texinfo.texi (listoffloats): * texinfo/texinfo.texi (Images): * texinfo/texinfo.texi (Image Syntax): * texinfo/texinfo.texi (Image Scaling): * texinfo/texinfo.texi (Footnotes): * texinfo/texinfo.texi (Footnote Commands): * texinfo/texinfo.texi (Footnote Styles): * texinfo/texinfo.texi (Indices): * texinfo/texinfo.texi (Index Entries): * texinfo/texinfo.texi (Predefined Indices): * texinfo/texinfo.texi (Indexing Commands): * texinfo/texinfo.texi (Combining Indices): * texinfo/texinfo.texi (syncodeindex): * texinfo/texinfo.texi (synindex): * texinfo/texinfo.texi (New Indices): * texinfo/texinfo.texi (Insertions): * texinfo/texinfo.texi (Atsign Braces Comma): * texinfo/texinfo.texi (Inserting an Atsign): * texinfo/texinfo.texi (Inserting Braces): * texinfo/texinfo.texi (Inserting a Comma): * texinfo/texinfo.texi (Inserting Quote Characters): * texinfo/texinfo.texi (Inserting Space): * texinfo/texinfo.texi (Not Ending a Sentence): * texinfo/texinfo.texi (Ending a Sentence): * texinfo/texinfo.texi (Multiple Spaces): * texinfo/texinfo.texi (frenchspacing): * texinfo/texinfo.texi (dmn): * texinfo/texinfo.texi (Inserting Accents): * texinfo/texinfo.texi (Inserting Quotation Marks): * texinfo/texinfo.texi (Dots Bullets): * texinfo/texinfo.texi (dots): * texinfo/texinfo.texi (bullet): * texinfo/texinfo.texi (TeX and copyright): * texinfo/texinfo.texi (tex): * texinfo/texinfo.texi (copyright symbol): * texinfo/texinfo.texi (registered symbol): * texinfo/texinfo.texi (euro): * texinfo/texinfo.texi (pounds): * texinfo/texinfo.texi (textdegree): * texinfo/texinfo.texi (minus): * texinfo/texinfo.texi (geq leq): * texinfo/texinfo.texi (math): * texinfo/texinfo.texi (Click Sequences): * texinfo/texinfo.texi (Glyphs): * texinfo/texinfo.texi (Glyphs Summary): * texinfo/texinfo.texi (result): * texinfo/texinfo.texi (expansion): * texinfo/texinfo.texi (Print Glyph): * texinfo/texinfo.texi (Error Glyph): * texinfo/texinfo.texi (Equivalence): * texinfo/texinfo.texi (Point Glyph): * texinfo/texinfo.texi (Breaks): * texinfo/texinfo.texi (Break Commands): * texinfo/texinfo.texi (Line Breaks): * texinfo/texinfo.texi (- and hyphenation): * texinfo/texinfo.texi (allowcodebreaks): * texinfo/texinfo.texi (w): * texinfo/texinfo.texi (tie): * texinfo/texinfo.texi (sp): * texinfo/texinfo.texi (page): * texinfo/texinfo.texi (group): * texinfo/texinfo.texi (need): * texinfo/texinfo.texi (Definition Commands): * texinfo/texinfo.texi (Def Cmd Template): * texinfo/texinfo.texi (Def Cmd Continuation Lines): * texinfo/texinfo.texi (Optional Arguments): * texinfo/texinfo.texi (deffnx): * texinfo/texinfo.texi (Def Cmds in Detail): * texinfo/texinfo.texi (Functions Commands): * texinfo/texinfo.texi (Variables Commands): * texinfo/texinfo.texi (Typed Functions): * texinfo/texinfo.texi (Typed Variables): * texinfo/texinfo.texi (Data Types): * texinfo/texinfo.texi (Abstract Objects): * texinfo/texinfo.texi (Object-Oriented Variables): * texinfo/texinfo.texi (Object-Oriented Methods): * texinfo/texinfo.texi (Defining Macros): * texinfo/texinfo.texi (Invoking Macros): * texinfo/texinfo.texi (Macro Details): * texinfo/texinfo.texi (alias): * texinfo/texinfo.texi (definfoenclose): * texinfo/texinfo.texi (Hardcopy): * texinfo/texinfo.texi (Use TeX): * texinfo/texinfo.texi (Format with tex/texindex): * texinfo/texinfo.texi (Format with texi2dvi): * texinfo/texinfo.texi (Print with lpr): * texinfo/texinfo.texi (Within XEmacs): * texinfo/texinfo.texi (Texinfo Mode Printing): * texinfo/texinfo.texi (Compile-Command): * texinfo/texinfo.texi (Requirements Summary): * texinfo/texinfo.texi (Preparing for TeX): * texinfo/texinfo.texi (Overfull hboxes): * texinfo/texinfo.texi (smallbook): * texinfo/texinfo.texi (A4 Paper): * texinfo/texinfo.texi (pagesizes): * texinfo/texinfo.texi (Cropmarks and Magnification): * texinfo/texinfo.texi (PDF Output): * texinfo/texinfo.texi (Obtaining TeX): * texinfo/texinfo.texi (Creating and Installing Info Files): * texinfo/texinfo.texi (Creating an Info File): * texinfo/texinfo.texi (makeinfo advantages): * texinfo/texinfo.texi (Invoking makeinfo): * texinfo/texinfo.texi (makeinfo options): * texinfo/texinfo.texi (Pointer Validation): * texinfo/texinfo.texi (makeinfo in XEmacs): * texinfo/texinfo.texi (texinfo-format commands): * texinfo/texinfo.texi (Batch Formatting): * texinfo/texinfo.texi (Tag and Split Files): * texinfo/texinfo.texi (Installing an Info File): * texinfo/texinfo.texi (Directory File): * texinfo/texinfo.texi (New Info File): * texinfo/texinfo.texi (Other Info Directories): * texinfo/texinfo.texi (Installing Dir Entries): * texinfo/texinfo.texi (Invoking install-info): * texinfo/texinfo.texi (Generating HTML): * texinfo/texinfo.texi (HTML Translation): * texinfo/texinfo.texi (HTML Splitting): * texinfo/texinfo.texi (HTML CSS): * texinfo/texinfo.texi (HTML Xref): * texinfo/texinfo.texi (HTML Xref Link Basics): * texinfo/texinfo.texi (HTML Xref Node Name Expansion): * texinfo/texinfo.texi (HTML Xref Command Expansion): * texinfo/texinfo.texi (HTML Xref 8-bit Character Expansion): * texinfo/texinfo.texi (HTML Xref Mismatch): * texinfo/texinfo.texi (Command List): * texinfo/texinfo.texi (Command Syntax): * texinfo/texinfo.texi (Tips): * texinfo/texinfo.texi (Sample Texinfo Files): * texinfo/texinfo.texi (Short Sample Texinfo File): * texinfo/texinfo.texi (GNU Sample Texts): * texinfo/texinfo.texi (Invoking sample): * texinfo/texinfo.texi (GNU Free Documentation License): * texinfo/texinfo.texi (Index): * texinfo/texinfo.texi (Verbatim Copying License): * texinfo/texinfo.texi (All-permissive Copying License): * texinfo/texinfo.texi (Include Files): * texinfo/texinfo.texi (Using Include Files): * texinfo/texinfo.texi (texinfo-multiple-files-update): * texinfo/texinfo.texi (Include Files Requirements): * texinfo/texinfo.texi (Sample Include File): * texinfo/texinfo.texi (Include Files Evolution): * texinfo/texinfo.texi (Headings): * texinfo/texinfo.texi (Headings Introduced): * texinfo/texinfo.texi (Heading Format): * texinfo/texinfo.texi (Heading Choice): * texinfo/texinfo.texi (Custom Headings): * texinfo/texinfo.texi (Catching Mistakes): * texinfo/texinfo.texi (makeinfo Preferred): * texinfo/texinfo.texi (Debugging with Info): * texinfo/texinfo.texi (Debugging with TeX): * texinfo/texinfo.texi (Using texinfo-show-structure): * texinfo/texinfo.texi (Using occur): * texinfo/texinfo.texi (Running Info-Validate): * texinfo/texinfo.texi (Using Info-validate): * texinfo/texinfo.texi (Unsplit): * texinfo/texinfo.texi (Tagifying): * texinfo/texinfo.texi (Splitting): * texinfo/texinfo.texi (Refilling Paragraphs): * texinfo/texinfo.texi (Command and Variable Index): * texinfo/texinfo.texi (General Index): * texinfo/version.texi: New file. Sync with FSF 23.1.92. Make new directory to hold the files needed to generate texinfo.info, since there are three such files now. 2010-02-19 Ben Wing <ben@xemacs.org> * Makefile: * Makefile (src_files1): * Makefile (DIR): * Makefile (texinfo-srcs): * Makefile ($(INFODIR)/widget.info): * Makefile ($(INFODIR)/texinfo.info): * Makefile (.PHONY): * Makefile (texinfo.dvi): * Makefile (texinfo.pdf): * Makefile ($(HTMLDIR)/widget.html): * Makefile ($(HTMLDIR)/texinfo.html): Incorporate texinfo.texi moving to a subdirectory texinfo/. Do some tricks to reduce the amount of duplication while still maintaining compatible with non-GNU make (at least, with Solaris make). * doclicense.texi: New file. * info.texi: * info.texi (Top): * info.texi (Getting Started): * info.texi (Help-Small-Screen): * info.texi (Help): * info.texi (Help-P): * info.texi (Help-^L): * info.texi (Help-Inv): * info.texi (Help-]): * info.texi (Help-M): * info.texi (Help-FOO): * info.texi (Help-Xref): * info.texi (Help-Int): * info.texi (Help-Q): * info.texi (Advanced): * info.texi (Search Text): * info.texi (Search Index): * info.texi (Go to node): * info.texi (Choose menu subtopic): * info.texi (Create Info buffer): * info.texi (XEmacs Info Variables): * info.texi (Expert Info): * info.texi (Add): * info.texi (Menus): * info.texi (Cross-refs): * info.texi (Help-Cross): * info.texi (Tags): * info.texi (Checking): * info.texi (Index): * texinfo.tex: * texinfo.tex (paragraphindent{%): * texinfo.tex (sectionheading will have): * texinfo.tex (chapterzzz{#3}%): * texinfo.tex (subsubsection = \numberedsubsubsec): * texinfo.tex (subsubsection = \appendixsubsubsec): * texinfo.tex (subsubsection = \unnumberedsubsubsec): * texinfo.tex (sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%): * texinfo.tex (sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%): * texinfo.tex (sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%): * texinfo.tex (sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%): * texinfo.tex (sectionheading{#1}{subsec}{Yappendix}%): * texinfo.tex (sectionheading{#1}{subsec}{Ynothing}%): * texinfo.tex (sectionheading{#1}{subsubsec}{Ynumbered}%): * texinfo.tex (sectionheading{#1}{subsubsec}{Yappendix}%): * texinfo.tex (sectionheading{#1}{subsubsec}{Ynothing}%): * texinfo.tex (sectionheading{#1}{subsubsec}{Yomitfromtoc}{}): * texinfo.tex (sectionheading to do the printing.): * texinfo.tex (sectionlevel}{#1}{#4}%): * texinfo.tex (sectionheading, q.v.): Sync with FSF 23.1.92.
author Ben Wing <ben@xemacs.org>
date Fri, 19 Feb 2010 22:39:19 -0600
parents 2ade80e8c640
children 1537701f08a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* strftime - custom formatting of date and/or time
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1989, 1991, 1992 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 along with this program; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
21 /* This file has been ... uhhhhh ... Mule-ized. Yeah.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
22
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
23 (Everything here is external format. This is DANGEROUS and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
24 data-lossy, but fixing it is too much of a bother now.) --ben */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
25
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 /* Note: this version of strftime lacks locale support,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 but it is standalone.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Performs `%' substitutions similar to those in printf. Except
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 where noted, substituted fields have a fixed size; numeric fields are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 padded if necessary. Padding is with zeros by default; for fields
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 that display a single number, padding can be changed or inhibited by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 following the `%' with one of the modifiers described below. Unknown
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 field specifiers are copied as normal characters. All other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 characters are copied to the output without change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Supports a superset of the ANSI C field specifiers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 Literal character fields:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 % %
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 n newline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 t tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 Numeric modifiers (a nonstandard extension):
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 - do not pad the field
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 _ pad the field with spaces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 Time fields:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 %H hour (00..23)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 %I hour (01..12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 %k hour ( 0..23)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 %l hour ( 1..12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 %M minute (00..59)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 %p locale's AM or PM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 %r time, 12-hour (hh:mm:ss [AP]M)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 %R time, 24-hour (hh:mm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 %s time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 %S second (00..61)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 %T time, 24-hour (hh:mm:ss)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 %X locale's time representation (%H:%M:%S)
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
61 %z time zone offset (e.g. +0530, -0800 etc)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 %Z time zone (EDT), or nothing if no time zone is determinable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 Date fields:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 %a locale's abbreviated weekday name (Sun..Sat)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 %A locale's full weekday name, variable length (Sunday..Saturday)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 %b locale's abbreviated month name (Jan..Dec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 %B locale's full month name, variable length (January..December)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 %c locale's date and time (Sat Nov 04 12:02:33 EST 1989)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 %C century (00..99)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 %d day of month (01..31)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 %e day of month ( 1..31)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 %D date (mm/dd/yy)
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
74 %G year corresponding to the ISO 8601 week
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
75 %g Year of the ISO 8601 week within century (00 - 99)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 %h same as %b
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 %j day of year (001..366)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 %m month (01..12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 %U week number of year with Sunday as first day of week (00..53)
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
80 %V ISO 8601 week number (first week is the earliest one with Thu)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 %w day of week (0..6)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 %W week number of year with Monday as first day of week (00..53)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 %x locale's date representation (mm/dd/yy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 %y last two digits of year (00..99)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 %Y year (1970...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 David MacKenzie <djm@gnu.ai.mit.edu> */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 #include <sys/time.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #include <time.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #ifndef STDC_HEADERS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 time_t mktime ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
106 #if defined(WIN32_NATIVE) || defined(CYGWIN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #include <time.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #if defined(HAVE_TZNAME)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 extern char *tzname[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
112 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 #define strftime emacs_strftime
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 /* Types of padding for numbers in date and time. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 enum padding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 none, blank, zero
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
124 static char const* const days[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
129 static char const * const months[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 "January", "February", "March", "April", "May", "June",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 "July", "August", "September", "October", "November", "December"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 /* Add character C to STRING and increment LENGTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 unless LENGTH would exceed MAX. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 #define add_char(c) do \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if (length + 1 <= max) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 string[length++] = (c); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 /* Add a 2 digit number to STRING, padding if specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 Return the number of characters added, up to MAX. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 add_num2 (char *string, int num, int max, enum padding pad)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 int top = num / 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 int length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 if (top == 0 && pad == blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 add_char (' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 else if (top != 0 || pad == zero)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 add_char (top + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 add_char (num % 10 + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 return length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* Add a 3 digit number to STRING, padding if specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Return the number of characters added, up to MAX. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 add_num3 (char *string, int num, int max, enum padding pad)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 int top = num / 100;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 int mid = (num - top * 100) / 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 int length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 if (top == 0 && pad == blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 add_char (' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 else if (top != 0 || pad == zero)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 add_char (top + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 if (mid == 0 && top == 0 && pad == blank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 add_char (' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 else if (mid != 0 || top != 0 || pad == zero)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 add_char (mid + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 add_char (num % 10 + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 return length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 /* Like strncpy except return the number of characters copied. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
186 add_str (char *to, const char *from, int max)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 for (i = 0; from[i] && i <= max; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 to[i] = from[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 add_num_time_t (char *string, int max, time_t num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 /* This buffer is large enough to hold the character representation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (including the trailing NUL) of any unsigned decimal quantity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 whose binary representation fits in 128 bits. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 char buf[40];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 if (sizeof (num) > 16)
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 793
diff changeset
204 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 sprintf (buf, "%lu", (unsigned long) num);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
206 return add_str (string, buf, max);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /* Return the week in the year of the time in TM, with the weeks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 starting on Sundays. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
213 sun_week (const struct tm *tm)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 int dl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* Set `dl' to the day in the year of the last day of the week previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 to the one containing the day specified in TM. If the day specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 in TM is in the first week of the year, `dl' will be negative or 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 Otherwise, calculate the number of complete weeks before our week
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 (dl / 7) and add any partial week at the start of the year (dl % 7). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 dl = tm->tm_yday - tm->tm_wday;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 /* Return the week in the year of the time in TM, with the weeks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 starting on Mondays. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
230 mon_week (const struct tm *tm)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 int dl, wday;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 if (tm->tm_wday == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 wday = 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 wday = tm->tm_wday - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 dl = tm->tm_yday - wday;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
242 #ifndef __isleap
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
243 /* Nonzero if YEAR is a leap year (every 4 years,
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
244 except every 100th isn't, and every 400th is). */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
245 # define __isleap(year) \
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
246 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
247 #endif
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
248
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
249 /* The number of days from the first day of the first ISO week of this
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
250 year to the year day YDAY with week day WDAY. ISO weeks start on
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
251 Monday; the first ISO week has the year's first Thursday. YDAY may
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
252 be as small as YDAY_MINIMUM. */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
253 #define ISO_WEEK_START_WDAY 1 /* Monday */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
254 #define ISO_WEEK1_WDAY 4 /* Thursday */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
255 #define YDAY_MINIMUM (-366)
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
256 static int
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
257 iso_week_days (int yday, int wday)
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
258 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
259 /* Add enough to the first operand of % to make it nonnegative. */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
260 int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
261 return (yday
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
262 - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
263 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
264 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
265
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 #if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
267 char *zone_name (const struct tm *tp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 char *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
269 zone_name (const struct tm *tp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 char *timezone ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 struct timeval tv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 struct timezone tz;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 gettimeofday (&tv, &tz);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 return timezone (tz.tz_minuteswest, tp->tm_isdst);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* Format the time given in TM according to FORMAT, and put the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 results in STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 Return the number of characters (not including terminating null)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 that were put into STRING, or 0 if the length would have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 exceeded MAX. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
286 size_t strftime (char *string, size_t max, const char *format,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
287 const struct tm *tm);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 size_t
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
290 strftime (char *string, size_t max, const char *format, const struct tm *tm)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 enum padding pad; /* Type of padding to apply. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 size_t length = 0; /* Characters put in STRING so far. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 for (; *format && length < max; ++format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 if (*format != '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 add_char (*format);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 ++format;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /* Modifiers: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 if (*format == '-')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 pad = none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 ++format;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 else if (*format == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 pad = blank;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 ++format;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 pad = zero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 switch (*format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 /* Literal character fields: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 add_char ('%');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 case 'n':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 add_char ('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 add_char ('\t');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 add_char (*format);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 /* Time fields: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 case 'k':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 add_num2 (&string[length], tm->tm_hour, max - length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 *format == 'H' ? pad : blank);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 case 'I':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 int hour12;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 if (tm->tm_hour == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 hour12 = 12;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 else if (tm->tm_hour > 12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 hour12 = tm->tm_hour - 12;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 hour12 = tm->tm_hour;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 add_num2 (&string[length], hour12, max - length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 *format == 'I' ? pad : blank);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 case 'M':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 add_num2 (&string[length], tm->tm_min, max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 if (tm->tm_hour < 12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 add_char ('A');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 add_char ('P');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 add_char ('M');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 strftime (&string[length], max - length, "%I:%M:%S %p", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 case 'R':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 strftime (&string[length], max - length, "%H:%M", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 case 's':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 struct tm writable_tm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 writable_tm = *tm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 length += add_num_time_t (&string[length], max - length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 mktime (&writable_tm));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 case 'S':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 add_num2 (&string[length], tm->tm_sec, max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 strftime (&string[length], max - length, "%H:%M:%S", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 break;
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
393
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
394 case 'V':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
395 case 'g':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
396 case 'G':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
397 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
398 int year = tm->tm_year + 1900;
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
399 int ndays = iso_week_days (tm->tm_yday, tm->tm_wday);
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
400
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
401 if (ndays < 0)
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
402 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
403 /* This ISO week belongs to the previous year. */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
404 year--;
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
405 ndays =
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
406 iso_week_days (tm->tm_yday + (365 + __isleap (year)),
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
407 tm->tm_wday);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
408 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
409 else
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
410 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
411 int d =
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
412 iso_week_days (tm->tm_yday - (365 + __isleap (year)),
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
413 tm->tm_wday);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
414 if (0 <= d)
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
415 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
416 /* This ISO week belongs to the next year. */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
417 year++;
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
418 ndays = d;
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
419 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
420 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
421
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
422 switch (*format)
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
423 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
424 /*
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
425 #### FIXME
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
426 We really can't assume 1000 <= year <= 9999
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
427 once time_t gets beyond 32 bits, but it's true
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
428 of the rest of the code here so get with the
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
429 program
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
430 */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
431 case 'g':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
432 length +=
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
433 add_num2 (&string[length], year % 100,
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
434 max - length, pad);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
435 break;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
436
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
437 case 'G':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
438 add_char (year / 1000 + '0');
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
439 length += add_num3 (&string[length], year % 1000,
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
440 max - length, zero);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
441 break;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
442
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
443 default:
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
444 length +=
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
445 add_num2 (&string[length], ndays / 7 + 1,
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
446 max - length, pad);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
447 break;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
448 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
449 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
450 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 case 'X':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 strftime (&string[length], max - length, "%H:%M:%S", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 break;
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
455 case 'z':
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
456 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
457 /*
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
458 #### FIXME: could use tm->tm_gmtoff if present. Since
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
459 the other code in xemacs does not do so we follow the
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
460 leaders (and don't add a autoconf macro to detect
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
461 its presence).
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
462 */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
463 long int offset;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
464 long int minutes;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
465 struct tm lt, *ut;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
466 time_t utc;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
467
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
468 lt = *tm;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
469 utc = mktime(&lt);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
470 ut = gmtime(&utc);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
471 /* assume that tm is valid so the others will be too! */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
472 assert( utc != (time_t) -1 && ut != NULL );
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
473
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
474 /* tm diff code below is based on mktime.c, glibc 2.3.2 */
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
475 {
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
476 int lt4, ut4, lt100, ut100, lt400, ut400;
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
477 int intervening_leap_days, years, ndays;
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
478
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
479 lt4 = (lt.tm_year >> 2) + (1900 >> 2) -
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
480 ! (lt.tm_year & 3);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
481 ut4 = (ut->tm_year >> 2) + (1900 >> 2) -
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
482 ! (ut->tm_year & 3);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
483 lt100 = lt4 / 25 - (lt4 % 25 < 0);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
484 ut100 = ut4 / 25 - (ut4 % 25 < 0);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
485 lt400 = lt100 >> 2;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
486 ut400 = ut100 >> 2;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
487 intervening_leap_days =
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
488 (lt4 - ut4) - (lt100 - ut100) + (lt400 - ut400);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
489 years = lt.tm_year - ut->tm_year;
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
490 ndays = (365 * years + intervening_leap_days
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
491 + (lt.tm_yday - ut->tm_yday));
5016
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
492 offset = (60 * (60 * (24 * ndays
2ade80e8c640 enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents: 4203
diff changeset
493 + (lt.tm_hour - ut->tm_hour))
4203
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
494 + (lt.tm_min - ut->tm_min))
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
495 + (lt.tm_sec - ut->tm_sec));
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
496 }
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
497
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
498 minutes = offset / ( offset < 0 ? -60 : 60 );
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
499
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
500 add_char ((offset < 0 ? '-' : '+'));
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
501
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
502 if ( minutes / 600 != 0 )
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
503 add_char (minutes / 600 + '0');
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
504 else if ( pad != none )
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
505 add_char ((pad == zero ? '0' : ' '));
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
506
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
507 length +=
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
508 add_num3 (&string[length],
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
509 ((minutes / 60 ) % 10) * 100 + (minutes % 60),
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
510 max - length, pad);
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
511 break;
0a63e5de7bdc [xemacs-hg @ 2007-10-02 19:31:30 by aidan]
aidan
parents: 2500
diff changeset
512 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 case 'Z':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 #ifdef HAVE_TM_ZONE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 length += add_str (&string[length], tm->tm_zone, max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 #ifdef HAVE_TZNAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 if (tm->tm_isdst && tzname[1] && *tzname[1])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 length += add_str (&string[length], tzname[1], max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 length += add_str (&string[length], tzname[0], max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 length += add_str (&string[length], zone_name (tm), max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 /* Date fields: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 case 'a':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 add_char (days[tm->tm_wday][0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 add_char (days[tm->tm_wday][1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 add_char (days[tm->tm_wday][2]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 case 'A':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 add_str (&string[length], days[tm->tm_wday], max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 case 'b':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 add_char (months[tm->tm_mon][0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 add_char (months[tm->tm_mon][1]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 add_char (months[tm->tm_mon][2]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 case 'B':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 add_str (&string[length], months[tm->tm_mon], max - length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 strftime (&string[length], max - length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 "%a %b %d %H:%M:%S %Z %Y", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 case 'C':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 add_num2 (&string[length], (tm->tm_year + 1900) / 100,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 case 'd':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 add_num2 (&string[length], tm->tm_mday, max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 add_num2 (&string[length], tm->tm_mday, max - length, blank);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 case 'D':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 strftime (&string[length], max - length, "%m/%d/%y", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 case 'j':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 add_num3 (&string[length], tm->tm_yday + 1, max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 case 'm':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 add_num2 (&string[length], tm->tm_mon + 1, max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 case 'U':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 add_num2 (&string[length], sun_week (tm), max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 case 'w':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 add_char (tm->tm_wday + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 case 'W':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 add_num2 (&string[length], mon_week (tm), max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 case 'x':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 strftime (&string[length], max - length, "%m/%d/%y", tm);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 case 'y':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 add_num2 (&string[length], tm->tm_year % 100,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 max - length, pad);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 case 'Y':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 add_char ((tm->tm_year + 1900) / 1000 + '0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 length +=
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 add_num3 (&string[length],
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 (1900 + tm->tm_year) % 1000, max - length, zero);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 add_char (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 return length - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 }