X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=draft%2Fman3%2Fstrftime.3;h=199663f03629fc38f3fdce64d7663c397e26886b;hb=4fe824747c7faf385ebddbeea1a89602416484c3;hp=2675a18d0ef031487960b6e62b3f5815f2ed8805;hpb=4098ba44b0a43ff980f70689be7c8ed69230e427;p=linuxjm%2FLDP_man-pages.git diff --git a/draft/man3/strftime.3 b/draft/man3/strftime.3 index 2675a18d..199663f0 100644 --- a/draft/man3/strftime.3 +++ b/draft/man3/strftime.3 @@ -1,5 +1,6 @@ .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" +.\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. @@ -19,6 +20,7 @@ .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. +.\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code @@ -32,688 +34,259 @@ .\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and .\" 'width' components of conversion specifications. .\" -.\" Japanese Version Copyright (c) 2000 HANATAKA Shinya -.\" all rights reserved. -.\" Translated 2000-10-10, HANATAKA Shinya -.\" Updated 2002-01-09, Kentaro Shirakata -.\" Updated 2002-01-14, Akihiro MOTOKI -.\" Updated 2005-02-26, Akihiro MOTOKI -.\" Updated 2005-04-17, Akihiro MOTOKI -.\" Updated 2005-12-05, Akihiro MOTOKI, LDP v2.16 -.\" Updated 2010-04-18, Akihiro MOTOKI, LDP v3.24 +.\"******************************************************************* .\" -.\"WORD: conversion specifier ÊÑ´¹»ØÄêʸ»ú -.\"WORD: conversion specification ÊÑ´¹»ØÄê -.\"WORD: modifier ½¤¾þ»Ò -.\"WORD: broken-down time Í×ÁÇÊ̤Î(»þ¹ï) -.\"WORD: Single UNIX Specification Åý°ì UNIX µ¬³Ê -.\"WORD: ISO\ 8601 week-based ISO\ 8601 ¤Î½µÃ±°Ìɽµ­ +.\" This file was generated with po4a. Translate the source file. .\" -.TH STRFTIME 3 2010-01-17 "GNU" "Linux Programmer's Manual" -.SH ̾Á° -.\"O strftime \- format date and time -strftime \- ÆüÉÕ¤ª¤è¤Ó»þ¹ï¤Îʸ»úÎó¤Ø¤ÎÊÑ´¹ -.SH ½ñ¼° +.\"******************************************************************* +.TH STRFTIME 3 2013\-06\-28 GNU "Linux Programmer's Manual" +.SH 名前 +strftime \- 日付および時刻の文字列への変換 +.SH 書式 .nf -.B #include +\fB#include \fP .sp -.BI "size_t strftime(char *" s ", size_t " max ", const char *" format , -.BI " const struct tm *" tm ); +\fBsize_t strftime(char *\fP\fIs\fP\fB, size_t \fP\fImax\fP\fB, const char *\fP\fIformat\fP\fB,\fP +\fB const struct tm *\fP\fItm\fP\fB);\fP .fi -.SH ÀâÌÀ -.\"O The -.\"O .BR strftime () -.\"O function formats the broken-down time \fItm\fP -.\"O according to the format specification \fIformat\fP and places the -.\"O result in the character array \fIs\fP of size \fImax\fP. -.BR strftime () -´Ø¿ô ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï \fItm\fP ¤ÎÆâÍƤò -\fIformat\fP ¤Ç»ØÄꤵ¤ì¤¿½ñ¼°»ØÄê¤Ë¤·¤¿¤¬¤Ã¤ÆÊÑ´¹¤·¡¢ -Ťµ \fImax\fP ¤Îʸ»úÎó \fIs\fP ¤Ë½ñ¤­¹þ¤à¡£ +.SH 説明 .\" FIXME POSIX says: Local timezone information is used as though .\" strftime() called tzset(). But this doesn't appear to be the case +\fBstrftime\fP() 関数 は、要素別の時刻 \fItm\fP の内容を \fIformat\fP で指定された書式指定にしたがって変換し、 長さ +\fImax\fP の文字列 \fIs\fP に書き込む。 .PP -.\"O The format specification is a null-terminated string and may contain -.\"O special character sequences called -.\"O .IR "conversion specifications", -.\"O each of which is introduced by a \(aq%\(aq character and terminated by -.\"O some other character known as a -.\"O .IR "conversion specifier character". -.\"O All other character sequences are -.\"O .IR "ordinary character sequences". -½ñ¼°»ØÄê¤Ï NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤Ç¤¢¤ê¡¢ -¡ÖÊÑ´¹»ØÄê (conversion specification)¡×¤È¸Æ¤Ð¤ì¤ëÆÃÊ̤Êʸ»úÎó¤ò -´Þ¤Þ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ -³Æ¡¹¤ÎÊÑ´¹»ØÄê¤Ï \(aq%\(aq ʸ»ú¤Ç»Ï¤Þ¤ê¡¢ -¡ÖÊÑ´¹»ØÄêʸ»ú (conversion specifier character)¡×¤È¸Æ¤Ð¤ì¤ë -²¿¤é¤«Â¾¤Îʸ»ú¤Ç½ªÃ¼¤µ¤ì¤ë¡£¾åµ­°Ê³°¤ÎÁ´¤Æ¤Îʸ»úÎó¤Ï -¡ÖÄ̾ï¤Îʸ»úÎó (ordinary character sequence)¡×¤È¤Ê¤ë¡£ +書式指定は NULL 終端された文字列であり、 「変換指定 (conversion specification)」と呼ばれる特別な文字列を +含まることができる。 各々の変換指定は \(aq%\(aq 文字で始まり、 「変換指定文字 (conversion specifier +character)」と呼ばれる 何らか他の文字で終端される。上記以外の全ての文字列は 「通常の文字列 (ordinary character +sequence)」となる。 .PP -.\"O The characters of ordinary character sequences (including the null byte) -.\"O are copied verbatim from \fIformat\fP to \fIs\fP. However, the characters -.\"O of conversion specifications are replaced as follows: -(NULL ¥Ð¥¤¥È¤â´Þ¤à) Ä̾ï¤Îʸ»úÎóÆâ¤Îʸ»ú¤Ï¡¢ -¤½¤Î¤Þ¤Þ \fIformat\fP ¤«¤é \fIs\fP ¤Ë¥³¥Ô¡¼¤µ¤ì¤ë¡£ -°ìÊý¡¢ÊÑ´¹»ØÄê¤Îʸ»ú¤Ï°Ê²¼¤Î¤è¤¦¤ËÃÖ´¹¤µ¤ì¤ë¡£ -.TP -.B %a -.\"O The abbreviated weekday name according to the current locale. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î¾Êά̾¡£ -.TP -.B %A -.\"O The full weekday name according to the current locale. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î´°Á´¤Ê̾Á°¡£ -.TP -.B %b -.\"O The abbreviated month name according to the current locale. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î¾Êά̾¡£ -.TP -.B %B -.\"O The full month name according to the current locale. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î´°Á´¤Ê̾Á°¡£ -.TP -.B %c -.\"O The preferred date and time representation for the current locale. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤¤¤Æ°ìÈÌŪ¤ÊÆüÉÕ¡¦»þ¹ï¤Îɽµ­¡£ -.TP -.B %C -.\"O The century number (year/100) as a 2-digit integer. (SU) -À¤µª (À¾Îñǯ¤Î¾å 2 ·å)¡£ (SU) -.TP -.B %d -.\"O The day of the month as a decimal number (range 01 to 31). -·îÆâÄÌ»»Æü (10 ¿Ê¿ôɽµ­) (01-31)¡£ -.TP -.B %D -.\"O Equivalent to -.\"O .BR %m/%d/%y . -.\"O (Yecch\(emfor Americans only. -.\"O Americans should note that in other countries -.\"O .B %d/%m/%y -.\"O is rather common. -.\"O ambiguous and should not be used.) (SU) -.B %m/%d/%y -¤ÈÅù²Á¡£(¤¦¤¨¤Ã¡¢¥¢¥á¥ê¥«ÀìÍѤÀ¡£¥¢¥á¥ê¥«°Ê³°¤Î¹ñ¤Ç¤Ï -.B %d/%m/%y -¤ÎÊý¤¬°ìÈÌŪ¤À¡£Ê¶¤é¤ï¤·¤¤¤Î¤Ç¡¢»ÈÍѤ¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£) (SU) -.TP -.B %e -.\"O Like -.\"O .BR %d , -.\"O the day of the month as a decimal number, but a leading -.\"O zero is replaced by a space. (SU) -.B %d -¤ÈƱÍͤ˷îÆâÄÌ»»Æü¤ò 10 ¿Ê¿ô¤Çɽ¸½¤¹¤ë¤¬¡¢ -1 ·å¤Î¾ì¹ç 10 ¤Î°Ì¤Ë¥¼¥í¤òÃÖ¤«¤º¥¹¥Ú¡¼¥¹¤òÃÖ¤¯¡£(SU) -.TP -.B %E -.\"O Modifier: use alternative format, see below. (SU) -ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£²¼µ­»²¾È¡£ (SU) -.TP -.B %F -.\"O Equivalent to -.\"O .B %Y-%m-%d -.\"O (the ISO\ 8601 date format). (C99) -.B %Y-%m-%d -¤ÈÅù²Á (ISO\ 8601 ·Á¼°¤ÎÆüÉÕ¥Õ¥©¡¼¥Þ¥Ã¥È)¡£ (C99) -.TP -.B %G -.\"O The ISO\ 8601 week-based year (see NOTES) with century as a decimal number. -.\"O The 4-digit year corresponding to the ISO week number (see -.\"O .BR %V ). -.\"O This has the same format and value as -.\"O .BR %Y , -.\"O except that if the ISO week number belongs to the previous or next year, -.\"O that year is used instead. (TZ) -ISO\ 8601 ½µÃ±°Ìɽµ­¤Îǯ (week-based year; ¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£ -À¤µª¤â 10 ¿Ê¿ô¤Çɽ¤¹¡£ -ISO ½µÈÖ¹æ -.RB ( %V -¤ò»²¾È) ¤ËÂбþ¤·¤¿ 4 ·å¤ÎÀ¾Îñǯ¡£ -¤³¤ì¤Ï´ðËÜŪ¤Ë¤Ï -.B %Y -¤ÈƱ¤¸·Á¼°¤À¤¬¡¢ISO ½µ¿ô¤¬Á°Ç¯¤äÍâǯ¤Ë¤Ê¤ë -¾ì¹ç¤Ë¤Ï¤½¤Îǯ¤¬»ÈÍѤµ¤ì¤ëÅÀ¤¬°Û¤Ê¤ë¡£(TZ) -.TP -.B %g -.\"O Like -.\"O .BR %G , -.\"O but without century, that is, with a 2-digit year (00-99). (TZ) -.B %G -¤ÈƱÍÍ¡£Ã¢¤·¡¢À¤µª¤ò´Þ¤Þ¤º²¼ 2 ·å¤Î¤ß¤òɽ¼¨ (00-99)¡£ (TZ) -.TP -.B %h -.\"O Equivalent to -.\"O .BR %b . -.\"O (SU) -.B %b -¤ÈÅù²Á (SU) -.TP -.B %H -.\"O The hour as a decimal number using a 24-hour clock (range 00 to 23). -24 »þ´Öɽµ­¤Ç¤Î»þ (hour)¡£ (00-23) -.TP -.B %I -.\"O The hour as a decimal number using a 12-hour clock (range 01 to 12). -12 »þ´Öɽµ­¤Ç¤Î»þ (hour)¡£ (01-12) -.TP -.B %j -.\"O The day of the year as a decimal number (range 001 to 366). -ǯ¤Î½é¤á¤«¤éÄÌ»»¤ÎÆü¿ô¡£ (001-366) -.TP -.B %k -.\"O The hour (24-hour clock) as a decimal number (range 0 to 23); -.\"O single digits are preceded by a blank. -.\"O (See also -.\"O .BR %H .) -.\"O (TZ) -24 »þ´Öɽµ­¤Ç¤Î»þ (0-23)¡£ -1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£ -.RB ( %H -¤â»²¾È) (TZ) -.TP -.B %l -.\"O The hour (12-hour clock) as a decimal number (range 1 to 12); -.\"O single digits are preceded by a blank. -.\"O (See also -.\"O .BR %I .) -.\"O (TZ) -12 »þ´Öɽµ­¤Ç¤Î»þ (0-12)¡£ -1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£ -.RB ( %I -¤â»²¾È) (TZ) -.TP -.B %m -.\"O The month as a decimal number (range 01 to 12). -·î (10 ¿Ê¿ôɽµ­)¡£ (01-12) -.TP -.B %M -.\"O The minute as a decimal number (range 00 to 59). -ʬ (10 ¿Ê¿ôɽµ­) (00-59) -.TP -.B %n -.\"O A newline character. (SU) -²þ¹Ô¡£ (SU) -.TP -.B %O -.\"O Modifier: use alternative format, see below. (SU) -ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£°Ê²¼¤ò»²¾È¡£(SU) -.TP -.B %p -.\"O Either "AM" or "PM" according to the given time value, or the -.\"O corresponding strings for the current locale. -.\"O Noon is treated as "PM" and midnight as "AM". -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë¡Ö¸áÁ°¡×¡Ö¸á¸å¡×¤ËÁêÅö¤¹¤ëʸ»úÎó¡£ -±Ñ¸ì¤Î¾ì¹ç¤Ë¤Ï "AM" ¤Þ¤¿¤Ï "PM" ¤È¤Ê¤ë¡£ -Àµ¸á¤Ï¡Ö¸á¸å¡×¡¢¿¿ÌëÃæ¤Ï¡Ö¸áÁ°¡×¤È¤·¤Æ°·¤ï¤ì¤ë¡£ -.TP -.B %P -.\"O Like -.\"O .B %p -.\"O but in lowercase: "am" or "pm" or a corresponding -.\"O string for the current locale. (GNU) -.B %p -¤ÈƱÍͤǤ¢¤ë¤¬¾®Ê¸»ú¤¬»ÈÍѤµ¤ì¤ë¡£ -±Ñ¸ì¤Î¾ì¹ç¤Ë¤Ï "am" ¤ä "pm" ¤È¤Ê¤ë¡£(GNU) -.TP -.B %r -.\"O The time in a.m. or p.m. notation. -.\"O In the POSIX locale this is equivalent to -.\"O .BR "%I:%M:%S %p" . -.\"O (SU) -¸áÁ°¡¦¸á¸å·Á¼°¤Ç¤Î»þ¹ï¡£ -POSIX ¥í¥±¡¼¥ë¤Ç¤Ï -.B "%I:%M:%S %p" -¤ÈÅù²Á¤Ç¤¢¤ë¡£(SU) -.TP -.B %R -.\"O The time in 24-hour notation (\fB%H:%M\fP). (SU) -.\"O For a version including the seconds, see -.\"O .B %T -.\"O below. -24 »þ´Öɽµ­¤Ç¤Î»þ¹ï¡¢ÉäÏɽ¼¨¤·¤Ê¤¤ -.RB ( %H:%M )¡£ -Éäò´Þ¤ó¤À¤â¤Î¤Ï°Ê²¼¤Î -.B %T -¤ò»²¾È¤¹¤ë¤³¤È¡£(SU) -.TP -.B %s -.\"O The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). (TZ) -µª¸µ (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) ¤«¤é¤ÎÉÿô¡£ (TZ) -.TP -.B %S -.\"O The second as a decimal number (range 00 to 60). -.\"O (The range is up to 60 to allow for occasional leap seconds.) -Éà (10 ¿Ê¿ôɽµ­) (00-60) -(»þ¡¹¤¢¤ë±¼ÉäËÂбþ¤¹¤ë¤¿¤á¡¢ÃͤÎÈÏ°Ï¤Ï 60 ¤Þ¤Ç¤È¤Ê¤Ã¤Æ¤¤¤ë) -.TP -.B %t -.\"O A tab character. (SU) -¥¿¥Öʸ»ú (SU) -.TP -.B %T -.\"O The time in 24-hour notation (\fB%H:%M:%S\fP). (SU) -24 »þ´Öɽµ­¤Î»þ´Ö (\fB%H:%M:%S\fP) (SU) -.TP -.B %u -.\"O The day of the week as a decimal, range 1 to 7, Monday being 1. -.\"O See also -.\"O .BR %w . -.\"O (SU) -½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ­) ¤«¡£·îÍËÆü¤ò 1 ¤È¤¹¤ë (1-7)¡£ -.B %w -¤â»²¾È¡£(SU) -.TP -.B %U -.\"O The week number of the current year as a decimal number, -.\"O range 00 to 53, starting with the first Sunday as the first day -.\"O of week 01. -.\"O See also -.\"O .B %V -.\"O and -.\"O .BR %W . -ǯ¤Î½é¤á¤«¤é¤ÎÄÌ»»¤Î½µÈÖ¹æ (10 ¿Ê¿ôɽµ­) (00-53)¡£ -¤½¤Îǯ¤ÎºÇ½é¤ÎÆüÍËÆü¤ò¡¢Âè 1 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£ -.B %V -¤È -.B %W -¤â»²¾È¤¹¤ë¤³¤È¡£ -.TP -.B %V -.\"O The ISO\ 8601 week number (see NOTES) of the current year as a decimal number, -.\"O range 01 to 53, where week 1 is the first week that has at least -.\"O 4 days in the new year. -.\"O See also -.\"O .B %U -.\"O and -.\"O .BR %W . -.\"O (SU) -ISO\ 8601 ·Á¼°¤Ç¤Îǯ¤Î»Ï¤á¤«¤é¤Î½µÈÖ¹æ (¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£ -10 ¿Ê¿ôɽµ­¤Ç¡¢01 ¤«¤é 53 ¤ÎÃͤȤʤ롣½µÈÖ¹æ¤Ï¡¢ -¿·¤·¤¤Ç¯¤¬¾¯¤Ê¤¯¤È¤â 4 Æü°Ê¾å´Þ¤Þ¤ì¤ëºÇ½é¤Î½µ¤ò 1 ¤È¤·¤Æ·×»»¤¹¤ë¡£ -.B %U -¤È -.B %W -¤â»²¾È¤Î¤³¤È¡£(SU) -.TP -.B %w -.\"O The day of the week as a decimal, range 0 to 6, Sunday being 0. -.\"O See also -.\"O .BR %u . -½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ­) ¤«¡£ÆüÍËÆü¤ò 0 ¤È¤¹¤ë¡£(0-6)¡£ -.B %u -¤â»²¾È¡£(SU) -.TP -.B %W -.\"O The week number of the current year as a decimal number, -.\"O range 00 to 53, starting with the first Monday as the first day of week 01. -ǯ¤Î½é¤á¤«¤é¤ÎÄÌ»»¤Î½µÈÖ¹æ (10 ¿Ê¿ôɽµ­) (00-53)¡£ -¤½¤Îǯ¤ÎºÇ½é¤Î·îÍËÆü¤ò¡¢Âè 1 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£ -.TP -.B %x -.\"O The preferred date representation for the current locale without the time. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤ÊÆüÉÕɽµ­¡£»þ¹ï¤Ï´Þ¤Þ¤Ê¤¤¡£ -.TP -.B %X -.\"O The preferred time representation for the current locale without the date. -¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤Ê»þ¹ïɽµ­¡£ÆüÉդϴޤޤʤ¤¡£ -.TP -.B %y -.\"O The year as a decimal number without a century (range 00 to 99). -À¾Îñ¤Î²¼2·å (À¤µªÉôʬ¤ò´Þ¤Þ¤Ê¤¤Ç¯) (00-99)¡£ -.TP -.B %Y -.\"O The year as a decimal number including the century. -À¤µªÉôʬ¤ò´Þ¤á¤¿ ( 4 ·å¤Î) À¾Îñǯ¡£ -.TP -.B %z -.\"O The -.\"O .I +hhmm -.\"O or -.\"O .I -hhmm -.\"O numeric timezone (that is, the hour and minute offset from UTC). (SU) -.I +hhmm -¤ä -.I -hhmm -¤Î·Á¼°¤Î¥¿¥¤¥à¥¾¡¼¥ó (UTC ¤Ø¤Î¥ª¥Õ¥»¥Ã¥È»þ´Ö)¡£(SU) -.TP -.B %Z -.\"O The timezone or name or abbreviation. -¥¿¥¤¥à¥¾¡¼¥ó¤Þ¤¿¤Ï¥¾¡¼¥ó̾¤Þ¤¿¤Ï¾Êά̾¡£ -.TP -.B %+ +(NULL バイトも含む) 通常の文字列内の文字は、 そのまま \fIformat\fP から \fIs\fP にコピーされる。 +一方、変換指定の文字は以下のように置換される。 +.TP +\fB%a\fP +現在のロケールにおける曜日の省略名。 +.TP +\fB%A\fP +現在のロケールにおける曜日の完全な名前。 +.TP +\fB%b\fP +現在のロケールにおける月の省略名。 +.TP +\fB%B\fP +現在のロケールにおける月の完全な名前。 +.TP +\fB%c\fP +現在のロケールにおいて一般的な日付・時刻の表記。 +.TP +\fB%C\fP +世紀 (西暦年の上 2 桁)。 (SU) +.TP +\fB%d\fP +月内通算日 (10 進数表記) (01\-31)。 +.TP +\fB%D\fP +\fB%m/%d/%y\fP と等価。(うえっ、アメリカ専用だ。アメリカ以外の国では \fB%d/%m/%y\fP +の方が一般的だ。紛らわしいので、使用すべきではない。) (SU) +.TP +\fB%e\fP +\fB%d\fP と同様に月内通算日を 10 進数で表現するが、 1 桁の場合 10 の位にゼロを置かずスペースを置く。(SU) +.TP +\fB%E\fP +別形式を使用する際の修飾子。下記参照。 (SU) +.TP +\fB%F\fP +\fB%Y\-%m\-%d\fP と等価 (ISO\ 8601 形式の日付フォーマット)。 (C99) +.TP +\fB%G\fP +ISO\ 8601 週単位表記の年 (week\-based year; 「注意」の節を参照)。 世紀も 10 進数で表す。 ISO 週番号 (\fB%V\fP +を参照) に対応した 4 桁の西暦年。 これは基本的には \fB%Y\fP と同じ形式だが、ISO 週数が前年や翌年になる +場合にはその年が使用される点が異なる。(TZ) +.TP +\fB%g\fP +\fB%G\fP と同様。但し、世紀を含まず下 2 桁のみを表示 (00\-99)。 (TZ) +.TP +\fB%h\fP +\fB%b\fP と等価 (SU) +.TP +\fB%H\fP +24 時間表記での時 (hour)。 (00\-23) +.TP +\fB%I\fP +12 時間表記での時 (hour)。 (01\-12) +.TP +\fB%j\fP +年の初めから通算の日数。 (001\-366) +.TP +\fB%k\fP +24 時間表記での時 (0\-23)。 1 桁の場合には前にゼロでなくスペースが置かれる。 (\fB%H\fP も参照) (TZ) +.TP +\fB%l\fP +12 時間表記での時 (0\-12)。 1 桁の場合には前にゼロでなくスペースが置かれる。 (\fB%I\fP も参照) (TZ) +.TP +\fB%m\fP +月 (10 進数表記)。 (01\-12) +.TP +\fB%M\fP +分 (10 進数表記) (00\-59) +.TP +\fB%n\fP +改行。 (SU) +.TP +\fB%O\fP +別形式を使用する際の修飾子。下記参照。 (SU) +.TP +\fB%p\fP +現在のロケールにおける「午前」「午後」に相当する文字列。 英語の場合には "AM" または "PM" となる。 +正午は「午後」、真夜中は「午前」として扱われる。 +.TP +\fB%P\fP +\fB%p\fP と同様であるが小文字が使用される。 英語の場合には "am" や "pm" となる。(GNU) +.TP +\fB%r\fP +午前・午後形式での時刻。 POSIX ロケールでは \fB%I:%M:%S %p\fP と等価である。(SU) +.TP +\fB%R\fP +24 時間表記での時刻、秒は表示しない (\fB%H:%M\fP)。 秒を含んだものは以下の \fB%T\fP を参照すること。(SU) +.TP +\fB%s\fP +紀元 (Epoch; 1970\-01\-01 00:00:00 +0000 (UTC)) からの秒数。 (TZ) +.TP +\fB%S\fP +秒 (10 進数表記) (00\-60) (時々ある閏秒に対応するため、値の範囲は 60 までとなっている) +.TP +\fB%t\fP +タブ文字 (SU) +.TP +\fB%T\fP +24 時間表記の時間 (\fB%H:%M:%S\fP) (SU) +.TP +\fB%u\fP +週の何番目の日 (10 進数表記) か。月曜日を 1 とする (1\-7)。 \fB%w\fP も参照。(SU) +.TP +\fB%U\fP +年の初めからの通算の週番号 (10 進数表記) (00\-53)。 その年の最初の日曜日を、第 1 週の始まりとして計算する。 \fB%V\fP と \fB%W\fP +も参照すること。 +.TP +\fB%V\fP +ISO\ 8601 形式での年の始めからの週番号 (「注意」の節を参照)。 10 進数表記で、01 から 53 の値となる。週番号は、 +新しい年が少なくとも 4 日以上含まれる最初の週を 1 として計算する。 \fB%U\fP と \fB%W\fP も参照のこと。(SU) +.TP +\fB%w\fP +週の何番目の日 (10 進数表記) か。日曜日を 0 とする。(0\-6)。 \fB%u\fP も参照。(SU) +.TP +\fB%W\fP +年の初めからの通算の週番号 (10 進数表記) (00\-53)。 その年の最初の月曜日を、第 1 週の始まりとして計算する。 +.TP +\fB%x\fP +現在のロケールで一般的な日付表記。時刻は含まない。 +.TP +\fB%X\fP +現在のロケールで一般的な時刻表記。日付は含まない。 +.TP +\fB%y\fP +西暦の下2桁 (世紀部分を含まない年) (00\-99)。 +.TP +\fB%Y\fP +世紀部分を含めた ( 4 桁の) 西暦年。 +.TP +\fB%z\fP +\fI+hhmm\fP や \fI\-hhmm\fP の形式のタイムゾーン (UTC へのオフセット時間)。(SU) +.TP +\fB%Z\fP +タイムゾーン名または省略名。 +.TP +\fB%+\fP .\" Nov 05 -- Not in Linux/glibc, but is in some BSDs (according to .\" their man pages) -.\"O The date and time in -.\"O .BR date (1) -.\"O format. (TZ) -.\"O (Not supported in glibc2.) -.BR date (1) -·Á¼°¤Ç¤ÎÆü»þ¡£(TZ) -(glibc2 ¤Ç¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤) -.TP -.B %% -.\"O A literal \(aq%\(aq character. -\(aq%\(aq ʸ»ú¡£ +\fBdate\fP(1) 形式での日時。(TZ) (glibc2 ではサポートされていない) +.TP +\fB%%\fP +\(aq%\(aq 文字。 .PP -.\"O Some conversion specifications can be modified by preceding the -.\"O conversion specifier character by the -.\"O .B E -.\"O or -.\"O .B O -.\"O .I modifier -.\"O to indicate that an alternative format should be used. -¤¤¤¯¤Ä¤«¤ÎÊÑ´¹»ØÄê¤Ç¤Ï¡¢ÊÑ´¹»ØÄêʸ»ú¤ÎÁ°¤Ë -.B E -¤ä -.B O -¡Ö½¤¾þ»Ò¡×¤òÃÖ¤¯¤³¤È¤Ë¤è¤Ã¤ÆÊ̽ñ¼°¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ -.\"O If the alternative format or specification does not exist for -.\"O the current locale, the behavior will be as if the unmodified -.\"O conversion specification were used. (SU) -¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤¤¤ÆÊ̽ñ¼°¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢ -Ä̾ï¤ÎÊÑ´¹»ØÄ꤬»ÈÍѤµ¤ì¤¿¤«¤Î¤è¤¦¤ËÆ°ºî¤¹¤ë (SU)¡£ -.\"O The Single UNIX Specification mentions -.\"O .BR %Ec , -.\"O .BR %EC , -.\"O .BR %Ex , -.\"O .BR %EX , -.\"O .BR %Ey , -.\"O .BR %EY , -.\"O .BR %Od , -.\"O .BR %Oe , -.\"O .BR %OH , -.\"O .BR %OI , -.\"O .BR %Om , -.\"O .BR %OM , -.\"O .BR %OS , -.\"O .BR %Ou , -.\"O .BR %OU , -.\"O .BR %OV , -.\"O .BR %Ow , -.\"O .BR %OW , -.\"O .BR %Oy , -.\"O where the effect of the -.\"O .B O -.\"O modifier is to use -.\"O alternative numeric symbols (say, roman numerals), and that of the -.\"O E modifier is to use a locale-dependent alternative representation. -Åý°ì UNIX µ¬³Ê (Single UNIX Specification) ¤Ç¤Ï -.BR %Ec , -.BR %EC , -.BR %Ex , -.BR %EX , -.BR %Ey , -.BR %EY , -.BR %Od , -.BR %Oe , -.BR %OH , -.BR %OI , -.BR %Om , -.BR %OM , -.BR %OS , -.BR %Ou , -.BR %OU , -.BR %OV , -.BR %Ow , -.BR %OW , -.BR %Oy , -¤Ë¤Ä¤¤¤Æµ­½Ò¤¬¤¢¤ë¡£¤³¤³¤Ç -.B O -½¤¾þ»Ò¤ÏÊÌ·Á¼°¤Î¿ôÃÍ (¥í¡¼¥Þ¿ô»ú¤È¤«) ¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¡£ -.B E -½¤¾þ»Ò¤Ï¥í¥±¡¼¥ë°Í¸¤ÎÊÌɽ¸½¤ò»ØÄꤹ¤ë¤Î¤Ë»ÈÍѤ¹¤ë¡£ -(ÌõÃí: -.B E -½¤¾þ»Ò¤ÏÆüËܤǻÈÍѤµ¤ì¤Æ¤¤¤ë¡Ö¾¼Ï¡סÖÊ¿À®¡× -¤Ê¤É¤Î¸µ¹æ¤Ë¤è¤ëǯɽµ­¤ò»ØÄꤹ¤ë¡£glibc 2.2 °Ê¹ß¤Ç¤Î¤ßÍ­¸ú) +いくつかの変換指定では、変換指定文字の前に \fBE\fP や \fBO\fP 「修飾子」を置くことによって別書式を使用するように指定することができる。 +現在のロケールにおいて別書式が存在しない場合には、 通常の変換指定が使用されたかのように動作する (SU)。 統一 UNIX 規格 (Single +UNIX Specification) では \fB%Ec\fP, \fB%EC\fP, \fB%Ex\fP, \fB%EX\fP, \fB%Ey\fP, \fB%EY\fP, +\fB%Od\fP, \fB%Oe\fP, \fB%OH\fP, \fB%OI\fP, \fB%Om\fP, \fB%OM\fP, \fB%OS\fP, \fB%Ou\fP, \fB%OU\fP, +\fB%OV\fP, \fB%Ow\fP, \fB%OW\fP, \fB%Oy\fP, について記述がある。ここで \fBO\fP 修飾子は別形式の数値 (ローマ数字とか) +を指定するために使用する。 \fBE\fP 修飾子はロケール依存の別表現を指定するのに使用する。 (訳注: \fBE\fP +修飾子は日本で使用されている「昭和」「平成」 などの元号による年表記を指定する。glibc 2.2 以降でのみ有効) .PP -.\"O The broken-down time structure \fItm\fP is defined in \fI\fP. -.\"O See also -.\"O .BR ctime (3). -Í×ÁÇÊ̤λþ¹ï¹½Â¤ÂÎ \fItm\fP ¤Î¾ÜºÙ¤Ï \fI\fP ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£ -.BR ctime (3) -¤â»²¾È¤¹¤ë¤³¤È¡£ -.\"O .SH "RETURN VALUE" -.SH ÊÖ¤êÃÍ -.\"O The -.\"O .BR strftime () -.\"O function returns the number of characters placed -.\"O in the array \fIs\fP, not including the terminating null byte, -.\"O provided the string, including the terminating null byte, fits. -.BR strftime () -´Ø¿ô¤Ïʸ»úÎó \fIs\fP ¤Ë³ÊǼ¤µ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£ -¤³¤Îʸ»ú¿ô¤Ë½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Ï´Þ¤Þ¤Ê¤¤¡£ -½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤ò³ÊǼ¤Ç¤­¤ë¤À¤±¤ÎÂ礭¤µ¤ò»ý¤Ã¤¿Ê¸»úÎó¤òÅϤ¹¤³¤È¡£ -.\"O Otherwise, it returns 0, and the contents of the array is undefined. -.\"O (This behavior applies since at least libc 4.4.4; -.\"O very old versions of libc, such as libc 4.4.1, -.\"O would return \fImax\fP if the array was too small.) -¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï 0 ¤òÊÖ¤·¡¢Ê¸»úÎó¤ÎÆâÍƤϽ¤Àµ¤µ¤ì¤Ê¤¤¡£ -(libc 4.4.4 °Ê¹ß¤Ç¤³¤ÎµóÆ°¤¬Å¬ÍѤµ¤ì¤Æ¤¤¤ë¡£ -libc 4.4.1 ¤Ê¤É¤ÎÈó¾ï¤Ë¸Å¤¤¥Ð¡¼¥¸¥ç¥ó¤Î libc ¤Ç¤Ï -ʸ»úÎó¤¬Ã»¤«²á¤®¤¿¾ì¹ç¤Ë¤Ï \fImax\fP ¤¬ÊÖ¤µ¤ì¤ë¡£) +要素別の時刻構造体 \fItm\fP の詳細は \fI\fP に定義されている。 \fBctime\fP(3) も参照すること。 +.SH 返り値 +Provided that the result string, including the terminating null byte, does +not exceed \fImax\fP bytes, \fBstrftime\fP() returns the number of bytes +(excluding the terminating null byte) placed in the array \fIs\fP. If the +length of the result string (including the terminating null byte) would +exceed \fImax\fP bytes, then \fBstrftime\fP() returns 0, and the contents of the +array are undefined. (This behavior applies since at least libc 4.4.4; very +old versions of libc, such as libc 4.4.1, would return \fImax\fP if the array +was too small.) .LP -.\"O Note that the return value 0 does not necessarily indicate an error; -.\"O for example, in many locales -.\"O .B %p -.\"O yields an empty string. -ÊÖ¤êÃÍ 0 ¤Ïɬ¤º¤·¤â¥¨¥é¡¼¤ò°ÕÌ£¤·¤Æ¤¤¤ëÌõ¤Ç¤Ï¤Ê¤¤¤Î¤ÇÃí°Õ¤¹¤ë¤³¤È¡£ -Î㤨¤Ð¡¢Â¿¤¯¤Î¥í¥±¡¼¥ë¤Ç¤Ï -.B %p -¤Ï¶õʸ»úÎó¤òÊÖ¤¹¡£ -.\"O .SH ENVIRONMENT -.SH ´Ä¶­ÊÑ¿ô -.\"O The environment variables -.\"O .B TZ -.\"O and -.\"O .B LC_TIME -.\"O are used. -´Ä¶­ÊÑ¿ô -.B TZ -¤È -.B LC_TIME -¤¬»ÈÍѤµ¤ì¤ë¡£ -(ÌõÃí: -.B LC_ALL -¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï -.B LC_TIME -¤è¤ê¤â¤½¤Á¤é¤¬Í¥À褵¤ì¤ë¡£ -.B LC_TIME -¤â -.B LC_ALL -¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï -.B LANG -¤¬»ÈÍѤµ¤ì¤ë¡£) -.\"O .SH "CONFORMING TO" -.SH ½àµò -SVr4, C89, C99. -.\"O There are strict inclusions between the set of conversions -.\"O given in ANSI C (unmarked), those given in the Single UNIX Specification -.\"O (marked SU), those given in Olson's timezone package (marked TZ), -.\"O and those given in glibc (marked GNU), except that -.\"O .B %+ -.\"O is not supported in glibc2. -.\"O On the other hand glibc2 has several more extensions. -.\"O POSIX.1 only refers to ANSI C; POSIX.2 describes under -.\"O .BR date (1) -.\"O several extensions that could apply to -.\"O .BR strftime () -.\"O as well. -¸Ä¡¹¤ÎÊÑ´¹¤¬¸·Ì©¤Ë¤É¤Îµ¬³Ê¤Ë´Þ¤Þ¤ì¤ë¤«¤Ï¡¢ -ANSI C (°õ¤Ê¤·)¡¢Åý°ì UNIX µ¬³Ê (SU°õ)¡¢Olson ¤Î timezone ¥Ñ¥Ã¥±¡¼¥¸ (TZ°õ)¡¢ -glibc Æȼ« (GNU°õ) ¤Ç¼¨¤·¤Æ¤¤¤ë¡£glibc2 ¤Ç¤Ï -.B %+ -¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢ -¤¤¤¯¤Ä¤«¤Î³ÈÄ¥¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¡£POSIX.1 ¤Ç¤Ï ANSI C ¤Î¤ß¤ò»²¾È¤·¤Æ¤¤¤ë¡£ -POSIX.2 ¤Î -.BR date (1) -¤Î¤È¤³¤í¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ë´ö¤Ä¤«¤Î³ÈÄ¥¤Ï -.BR strftime () -¤Ë¤âŬÍѤǤ­¤ë¤À¤í¤¦¡£ -.\"O The -.\"O .B %F -.\"O conversion is in C99 and POSIX.1-2001. -.B %F -ÊÑ´¹¤Ï C99 ¤È POSIX.1-2001 ¤Ë¤¢¤ë¡£ +返り値 0 は必ずしもエラーを意味している訳ではないので注意すること。 例えば、多くのロケールでは \fB%p\fP は空文字列を返す。 同様に、空の +\fIformat\fP 文字列は空文字列を返す。 +.SH 環境変数 +環境変数 \fBTZ\fP と \fBLC_TIME\fP が使用される。 (訳注: \fBLC_ALL\fP が設定されている場合には \fBLC_TIME\fP +よりもそちらが優先される。 \fBLC_TIME\fP も \fBLC_ALL\fP も設定されていない場合には \fBLANG\fP が使用される。) +.SH 準拠 +SVr4, C89, C99. 個々の変換が厳密にどの規格に含まれるかは、 ANSI C (印なし)、統一 UNIX 規格 (SU印)、Olson の +timezone パッケージ (TZ印)、 glibc 独自 (GNU印) で示している。glibc2 では \fB%+\fP はサポートされていないが、 +いくつかの拡張が行われている。POSIX.1 では ANSI C のみを参照している。 POSIX.2 の \fBdate\fP(1) +のところに記述されている幾つかの拡張は \fBstrftime\fP() にも適用できるだろう。 \fB%F\fP 変換は C99 と POSIX.1\-2001 +にある。 -.\"O In SUSv2, the -.\"O .B %S -.\"O specifier allowed a range of 00 to 61, -.\"O to allow for the theoretical possibility of a minute that -.\"O included a double leap second -.\"O (there never has been such a minute). -SUSv2 ¤Ç¤Ï¡¢ -.B %S -¤Ï 00 ¤«¤é 61 ¤ÎÈϰϤò¤È¤ë¤Èµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£ -¤³¤ì¤Ï¡¢1ʬ´Ö¤Î¤¦¤Á±¼Éä¬ 2¤ÄÆþ¤ë²ÄǽÀ­¤¬ÍýÏÀŪ¤Ë¤Ï¤¢¤ë¤³¤È¤ò -¹Íθ¤·¤Æ¤Î¤â¤Î¤Ç¤¢¤ë (¼ÂºÝ¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ï¤³¤ì¤Þ¤Ç°ìÅÙ¤â -µ¯¤³¤Ã¤Æ¤¤¤Ê¤¤)¡£ -.\"O .SH NOTES -.SH Ãí°Õ -.\"O .SS ISO 8601 Week Dates -.SS ISO\ 8601 ¤Î½µ¡¦ÍËÆüɽµ­ (Week Dates) -.\"O .BR %G , -.\"O .BR %g , -.\"O and -.\"O .BR %V -.\"O yield values calculated from the week-based year defined by the -.\"O ISO\ 8601 standard. -.BR %G , -.BR %g , -.BR %V -¤Ï¡¢ISO\ 8601 ɸ½à¤Ë¤è¤êÄêµÁ¤µ¤ì¤¿½µÃ±°Ìɽµ­¤Îǯ¤Ë¤è¤ê -·×»»¤µ¤ì¤ëÃͤò½ÐÎϤ¹¤ë¡£ -.\"O In this system, weeks start on a Monday, and are numbered from 01, -.\"O for the first week, up to 52 or 53, for the last week. -.\"O Week 1 is the first week where four or more days fall within the -.\"O new year (or, synonymously, week 01 is: -.\"O the first week of the year that contains a Thursday; -.\"O or, the week that has 4 January in it). -ISO\ 8601 ɸ½à¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢½µ¤Ï·îÍËÆü¤«¤é³«»Ï¤µ¤ì¡¢ -½µÈÖ¹æ¤Ï¡¢Ç¯¤ÎºÇ½é¤Î½µ¤¬ 01 ¤È¤Ê¤ê¡¢ºÇ¸å¤Î½µ¤Ï 52 ¤« 53 ¤È¤Ê¤ë¡£ -½µ 01 ¤Ï¡¢¿·¤·¤¤Ç¯¤¬ 4 Æü°Ê¾å´Þ¤Þ¤ì¤ëºÇ½é¤Î½µ¤Ç¤¢¤ë¡£ -¸À¤¤´¹¤¨¤ë¤È¡¢½µ 01 ¤Ï¡¢¤½¤Îǯ¤ÎÌÚÍËÆü¤ò´Þ¤àºÇ½é¤Î½µ¡¢ -¤Ä¤Þ¤ê 1 ·î 4 Æü¤ò´Þ¤à½µ¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡£ -.\"O When three of fewer days of the first calendar week of the new year fall -.\"O within that year, -.\"O then the ISO 8601 week-based system counts those days as part of week 53 -.\"O of the preceding year. -¿·¤·¤¤Ç¯¤Î¥«¥ì¥ó¥À¡¼¾å¤ÎºÇ½é¤Î½µ¤Ë¿·¤·¤¤Ç¯¤¬ 3 Æü°Ê²¼¤·¤«´Þ¤Þ¤ì¤Ê¤¤¾ì¹ç¡¢ -ISO\ 8601 ¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢¤³¤ì¤é¤ÎÆü¤òÁ°¤Îǯ¤Î½µ 53 ¤Î°ìÉô¤È¤ß¤Ê¤¹¡£ -.\"O For example, 1 January 2010 is a Friday, -.\"O meaning that just three days of that calendar week fall in 2010. -.\"O Thus, the ISO\ 8601 week-based system considers these days to be part of -.\"O week 53 (\fB%V\fP) of the year 2009 (\fB%G\fP) ; -.\"O week 01 of ISO\ 8601 year 2010 starts on Monday, 4 January 2010. -Î㤨¤Ð¡¢2010 ǯ 1 ·î 1 Æü¤Ï¶âÍËÆü¤Ç¤¢¤ê¡¢ -¤½¤Î½µ¤Ë¤Ï 2010 ǯ¤ÎÆü¤¬ 3 Æü¤·¤«´Þ¤Þ¤ì¤Ê¤¤¡£ -¤·¤¿¤¬¤Ã¤Æ¡¢ISO\ 8601 ¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢¤³¤ì¤é¤ÎÆü¤Ï 2009 ǯ (\fB%G\fP) -¤Î½µ 53 (\fB%V\fP) ¤Î°ìÉô¤È¤Ê¤ë¡£ -ISO\ 8601 ¤Î 2010 ǯ¤Î½µ 01 ¤Ï 2010 ǯ 1 ·î 4 Æü¤Î·îÍËÆü¤«¤é»Ï¤Þ¤ë¡£ -.\"O .SS Glibc Notes -.SS glibc ¤Ç¤ÎÃí°Õ -.\"O Glibc provides some extensions for conversion specifications. -.\"O (These extensions are not specified in POSIX.1-2001, but a few other -.\"O systems provide similar features.) -.\"O .\" HP-UX and Tru64 also have features like this. -.\"O Between the \(aq%\(aq character and the conversion specifier character, -.\"O an optional -.\"O .I flag -.\"O and field -.\"O .I width -.\"O may be specified. -.\"O (These precede the -.\"O .B E -.\"O or -.\"O .B O -.\"O modifiers, if present.) -glibc ¤Ç¤ÏÊÑ´¹»ØÄê¤Ë¤¤¤¯¤Ä¤«³ÈÄ¥¤ò¹Ô¤Ã¤Æ¤¤¤ë -(¤³¤ì¤é¤Î³ÈÄ¥¤Ï POSIX.1-2001 ¤Ë¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢ -¾¤Î¤¤¤¯¤Ä¤«¤Î¥·¥¹¥Æ¥à¤ÇƱÍͤε¡Ç½¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë)¡£ -.\" HP-UX ¤È Tru64 ¤Ë¤âƱÍͤε¡Ç½¤¬¤¢¤ë¡£ -\(aq%\(aq ʸ»ú¤ÈÊÑ´¹»ØÄêʸ»ú¤Î´Ö¤Ë¡¢¥ª¥×¥·¥ç¥ó¤È¤·¤Æ -.I flag -¤È¥Õ¥£¡¼¥ë¥É¤Î -.I Éý -¤ò»ØÄê¤Ç¤­¤ë (¤³¤ì¤é¤ò»ØÄꤹ¤ë¾ì¹ç¤Ë¤Ï -.B E -¤ä -.B O -½¤¾þ»Ò¤ÎÁ°¤ËÃÖ¤¯)¡£ +SUSv2 では、 \fB%S\fP は 00 から 61 の範囲をとると規定されている。 これは、1分間のうち閏秒が 2つ入る可能性が理論的にはあることを +考慮してのものである (実際には、このような状況はこれまで一度も 起こっていない)。 +.SH 注意 +.SS "ISO\ 8601 の週・曜日表記 (Week Dates)" +\fB%G\fP, \fB%g\fP, and \fB%V\fP yield values calculated from the week\-based year +defined by the ISO\ 8601 standard. In this system, weeks start on a Monday, +and are numbered from 01, for the first week, up to 52 or 53, for the last +week. Week 1 is the first week where four or more days fall within the new +year (or, synonymously, week 01 is: the first week of the year that contains +a Thursday; or, the week that has 4 January in it). When three of fewer +days of the first calendar week of the new year fall within that year, then +the ISO 8601 week\-based system counts those days as part of week 53 of the +preceding year. For example, 1 January 2010 is a Friday, meaning that just +three days of that calendar week fall in 2010. Thus, the ISO\ 8601 +week\-based system considers these days to be part of week 53 (\fB%V\fP) of the +year 2009 (\fB%G\fP); week 01 of ISO\ 8601 year 2010 starts on Monday, 4 +January 2010. +.SS "glibc での注意" +.\" HP-UX and Tru64 also have features like this. +glibc では変換指定にいくつか拡張を行っている (これらの拡張は POSIX.1\-2001 には規定されていないが、 +他のいくつかのシステムで同様の機能が提供されている)。 \(aq%\(aq 文字と変換指定文字の間に、オプションとして \fIflag\fP とフィールドの +\fI幅\fP を指定できる (これらを指定する場合には \fBE\fP や \fBO\fP 修飾子の前に置く)。 -.\"O The following flag characters are permitted: -°Ê²¼¤Î¥Õ¥é¥°Ê¸»ú¤¬»ÈÍѤǤ­¤ë: -.TP -.B _ -.\"O (underscore) -.\"O Pad a numeric result string with spaces. -(²¼Àþ) -¿ôÃͤηë²Ìʸ»úÎó¤Î¥Ñ¥Ç¥£¥ó¥° (·êËä¤á) ¤ò¥¹¥Ú¡¼¥¹ (¶õÇòʸ»ú) ¤Ç¹Ô¤¦¡£ -.TP -.B \- -.\"O (dash) -.\"O Do not pad a numeric result string. -(¥À¥Ã¥·¥å) -¿ôÃͤηë²Ìʸ»úÎó¤ËÂФ¹¤ë¥Ñ¥Ç¥£¥ó¥°¤ò¹Ô¤ï¤Ê¤¤¡£ -.TP -.B 0 -.\"O Pad a numeric result string with zeros even if the conversion -.\"O specifier character uses space-padding by default. -ÊÑ´¹»ØÄêʸ»ú¤¬¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥¹¥Ú¡¼¥¹¤Ç¥Ñ¥Ç¥£¥ó¥°¤ò¹Ô¤¦¾ì¹ç¤Ç¤â¡¢ -¿ôÃͤηë²Ìʸ»úÎó¤Ø¤Î¥Ñ¥Ç¥£¥ó¥°¤ò 0 ¤Ç¹Ô¤¦¡£ -.TP -.B ^ -.\"O Convert alphabetic characters in result string to upper case. -·ë²Ìʸ»úÎóÃæ¤Î¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¤òÂçʸ»ú¤ËÊÑ´¹¤¹¤ë¡£ -.TP -.B # -.\"O Swap the case of the result string. -.\"O (This flag only works with certain conversion specifier characters, -.\"O and of these, it is only really useful with -.\"O .BR %Z .) -·ë²Ìʸ»úÎó¤ÎÂçʸ»ú¡¦¾®Ê¸»ú¤òÆþ¤ìÂؤ¨¤ë -(¤³¤Î¥Õ¥é¥°¤ÏÆÃÄê¤ÎÊÑ´¹»ØÄêʸ»ú¤Ç¤·¤«µ¡Ç½¤·¤Ê¤¤¡£¤½¤ÎÃæ¤Ç¤â -ËÜÅö¤ËÍ­ÍÑ¤Ê¤Î¤Ï -.B %Z -¤Î¾ì¹ç¤À¤±¤Ç¤¢¤ë)¡£ +以下のフラグ文字が使用できる: +.TP +\fB_\fP +(下線) 数値の結果文字列のパディング (穴埋め) をスペース (空白文字) で行う。 +.TP +\fB\-\fP +(ダッシュ) 数値の結果文字列に対するパディングを行わない。 +.TP +\fB0\fP +変換指定文字がデフォルトではスペースでパディングを行う場合でも、 数値の結果文字列へのパディングを 0 で行う。 +.TP +\fB^\fP +結果文字列中のアルファベット文字を大文字に変換する。 +.TP +\fB#\fP +結果文字列の大文字・小文字を入れ替える (このフラグは特定の変換指定文字でしか機能しない。その中でも 本当に有用なのは \fB%Z\fP の場合だけである)。 .PP -.\"O An optional decimal width specifier may follow the (possibly absent) flag. -.\"O If the natural size of the field is smaller than this width, -.\"O then the result string is padded (on the left) to the specified width. -¥ª¥×¥·¥ç¥ó¤Î10¿Ê¿ô¤ÎÉý»ØÄê»Ò¤Ï¥Õ¥é¥°¤Î¸å¤í¤ËÃÖ¤¯¤³¤È¤¬¤Ç¤­¤ë -(¥Õ¥é¥°¤Ï¤Ê¤¯¤Æ¤â¤è¤¤)¡£¥Õ¥£¡¼¥ë¥É¤ÎËÜÍè¤ÎÂ礭¤µ¤¬»ØÄꤵ¤ì¤¿Éý¤è¤ê¤â -¾®¤µ¤¤¾ì¹ç¡¢·ë²Ìʸ»úÎó¤Îº¸Â¦¤Ï»ØÄꤵ¤ì¤¿Éý¤Þ¤Ç¥Ñ¥Ç¥£¥ó¥°¤µ¤ì¤ë¡£ -.\"O .SH BUGS -.SH ¥Ð¥° -.\"O Some buggy versions of -.\"O .BR gcc (1) -.\"O complain about the use of -.\"O .BR %c : -.\"O .IR "warning: `%c' yields only last 2 digits of year in some locales" . -.BR gcc (1) -¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤Ï¤ª¤«¤·¤Ê¤È¤³¤í¤¬¤¢¤ê¡¢ -.B %c -¤Î»ÈÍÑË¡¤Ë¤Ä¤¤¤Æ°Ê²¼¤Î¤è¤¦¤Ê·Ù¹ð¤ò½Ð¤¹: -.I "warning: `%c' yields only last 2 digits of year in some locales" -.RI ( ·Ù¹ð: ¤¤¤¯¤Ä¤«¤Î¥í¥±¡¼¥ë¤Ç¤Ï `%c' ¤Ïǯ¤Î²¼2·å¤·¤«½ÐÎϤ·¤Ê¤¤ )¡£ -.\"O Of course programmers are encouraged to use -.\"O .BR %c , -.\"O it gives the preferred date and time representation. -.\"O One meets all kinds of strange obfuscations -.\"O to circumvent this -.\"O .BR gcc (1) -.\"O problem. -.\"O A relatively clean one is to add an -.\"O intermediate function -¤â¤Á¤í¤ó¥×¥í¥°¥é¥Þ¤¬ -.B %c -¤ò»È¤¦¤Î¤Ï¤ªÁ¦¤á¤Ç¤­¤ë¤³¤È¤Ç¤¢¤ë¡£ -.B %c -¤ò»È¤¦¤ÈŬÀÚ¤ÊÆüÉդȻþ¹ï¤Îɽµ­¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¤«¤é¤Ç¤¢¤ë¡£ -.BR gcc (1) -¤Î¤³¤ÎÌäÂê¤ò²óÈò¤·¤è¤¦¤È¤¹¤ë¤È¡¢²¿¤«¤¹¤Ã¤­¤ê¤·¤Ê¤¤µ¤Ê¬¤Ë¤Ê¤ë¤À¤í¤¦¡£ -Èæ³ÓŪ¤­¤ì¤¤¤Ê²ò·èÊýË¡¤Ï°Ê²¼¤Î¤è¤¦¤ÊÃæ´Ö´Ø¿ô¤òÄɲ乤뤳¤È¤Ç¤¢¤ë¡£ +オプションの10進数の幅指定子はフラグの後ろに置くことができる (フラグはなくてもよい)。フィールドの本来の大きさが指定された幅よりも +小さい場合、結果文字列の左側は指定された幅までパディングされる。 +.SH バグ +If the output string would exceed \fImax\fP bytes, \fIerrno\fP is \fInot\fP set. +This makes it impossible to distinguish this error case from cases where the +\fIformat\fP string legitimately produces a zero\-length output string. +POSIX.1\-2001 does \fInot\fP specify any \fIerrno\fP settings for \fBstrftime\fP(). + +\fBgcc\fP(1) のいくつかのバージョンにはおかしなところがあり、 \fB%c\fP の使用法について以下のような警告を出す: \fIwarning: +`%c' yields only last 2 digits of year in some locales\fP +(\fI警告:\fPいくつかのロケールでは\fI`%c'\fPは年の下2桁しか出力しない\fI)。\fP もちろんプログラマが \fB%c\fP +を使うのはお薦めできることである。 \fB%c\fP を使うと適切な日付と時刻の表記を得ることができるからである。 \fBgcc\fP(1) +のこの問題を回避しようとすると、何かすっきりしない気分になるだろう。 比較的きれいな解決方法は以下のような中間関数を追加することである。 .in +4n .nf @@ -725,60 +298,36 @@ my_strftime(char *s, size_t max, const char *fmt, } .fi .in -.RE -.\"O Nowadays, -.\"O .BR gcc (1) -.\"O provides the \fI\-Wno\-format\-y2k\fP option to prevent the warning, -.\"O so that the above workaround is no longer required. -¸½ºß¤Ç¤Ï¡¢ -.BR gcc (1) -¤Ï¤³¤Î·Ù¹ð¤òÍÞ¤¨¤ë¤¿¤á¤Î \fI\-Wno\-format\-y2k\fP ¥ª¥×¥·¥ç¥ó¤ò -Ä󶡤·¤Æ¤ª¤ê¡¢¾åµ­¤Î²óÈòºö¤Ï¤â¤Ï¤äɬÍפʤ¤¡£ -.\"O .SH EXAMPLES -.SH Îã -.\"O .BR "RFC\ 2822-compliant date format" -.\"O (with an English locale for %a and %b) -.B "RFC\ 2822 ½àµò¤ÎÆüÉÕ·Á¼°" -(%a ¤È %b ¤Ï±Ñ¸ì¥í¥±¡¼¥ë) +現在では、 \fBgcc\fP(1) はこの警告を抑えるための \fI\-Wno\-format\-y2k\fP オプションを +提供しており、上記の回避策はもはや必要ない。 +.SH 例 +\fBRFC\ 2822 準拠の日付形式\fP (%a と %b は英語ロケール) .PP .in +2n "%a,\ %d\ %b\ %Y\ %T\ %z" .PP -.\"O .BR "RFC\ 822-compliant date format" -.\"O (with an English locale for %a and %b) -.B "RFC\ 822 ½àµò¤ÎÆüÉÕ·Á¼°" -(%a ¤È %b ¤Ï±Ñ¸ì¥í¥±¡¼¥ë) +\fBRFC\ 822 準拠の日付形式\fP (%a と %b は英語ロケール) .PP .in +2n "%a,\ %d\ %b\ %y\ %T\ %z" -.\"O .SS Example Program -.SS ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à -.\"O The program below can be used to experiment with -.\"O .BR strftime (). -°Ê²¼¤Î¥×¥í¥°¥é¥à¤ò»È¤¦¤È -.BR strftime () -¤Î¼Â¸³¤¬¤Ç¤­¤ë¡£ +.SS サンプルプログラム +以下のプログラムを使うと \fBstrftime\fP() の実験ができる。 .PP -.\"O Some examples of the result string produced by the glibc implementation of -.\"O .BR strftime () -.\"O are as follows: -°Ê²¼¤Ë¡¢ -.BR strftime () -¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹: +以下に、 \fBstrftime\fP() の glibc 実装が生成する結果の例をいくつか示す: +.in +4n .nf -.RB "$" " ./a.out \(aq%m\(aq" +$\fB ./a.out \(aq%m\(aq\fP Result string is "11" -.RB "$" " ./a.out \(aq%5m\(aq" +$\fB ./a.out \(aq%5m\(aq\fP Result string is "00011" -.RB "$" " ./a.out \(aq%_5m\(aq" +$\fB ./a.out \(aq%_5m\(aq\fP Result string is " 11" .fi .in .PP -.\"O Here's the program source: -¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹¤Ï°Ê²¼¤ÎÄ̤ê: +プログラムのソースは以下の通り: .nf #include @@ -789,22 +338,6 @@ int main(int argc, char *argv[]) { char outstr[200]; -.PP -.\"O Some examples of the result string produced by the glibc implementation of -.\"O .BR strftime () -.\"O are as follows: -°Ê²¼¤Ë¡¢ -.BR strftime () -¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹: -.nf - -$ ./a.out "%m" -Result string is "11" -$ ./a.out "%5m" -Result string is "00011" -$ ./a.out "%_5m" -Result string is " 11" -.fi time_t t; struct tm *tmp; @@ -820,15 +353,14 @@ Result string is " 11" exit(EXIT_FAILURE); } - printf("Result string is \\"%s\\"\\n", outstr); + printf("Result string is \e"%s\e"\en", outstr); exit(EXIT_SUCCESS); } .fi -.\"O .SH "SEE ALSO" -.SH ´ØÏ¢¹àÌÜ -.BR date (1), -.BR time (2), -.BR ctime (3), -.BR setlocale (3), -.BR sprintf (3), -.BR strptime (3) +.SH 関連項目 +\fBdate\fP(1), \fBtime\fP(2), \fBctime\fP(3), \fBsetlocale\fP(3), \fBsprintf\fP(3), +\fBstrptime\fP(3) +.SH この文書について +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部 +である。プロジェクトの説明とバグ報告に関する情報は +http://www.kernel.org/doc/man\-pages/ に書かれている。