2012-07-21 653 views
0

以下功能中“%X”和“%x”之间的区别是什么?格式化时间字符串中%X和%x有什么区别?

(defvar insert-time-format "%X" 
"*Format for \\[insert-time] (c.f. 'format-time-string').") 

----------- 

(defvar insert-date-format "%x" 
"*Format for \\[insert-date] (c.f. 'format-time-string').") 

回答

1

明显,如果你看到的插入时间格式的描述,你会看到:

%x是语言环境的“首选”日期格式。

%X是语言环境的“首选”时间格式。

+0

哦,是的!你对,thx – Daniel 2012-07-21 15:11:52

-1

%x将输入格式化为十六进制。 %x和%X的区别在于这些字母是用大写字母写的。

E.g.

%×,15为f

%X,15会为F

+2

他谈到其他格式,而不是(格式...) – alinsoar 2012-07-21 15:11:08

1
%x inserts the time. 
%X inserts the date. 
1

你也许需要一个很好的猜测基础上的变量名insert-time-formatinsert-date-format不同,但是之后,你的第一个停靠港应该是它在帮助中提到的format-time-string功能的帮助两种这些变量:

˚Fformat-time-stringRET

format-time-string is a built-in function in `C source code'. 

(format-time-string FORMAT-STRING &optional TIME UNIVERSAL) 

Use FORMAT-STRING to format the time TIME, or now if omitted. 
TIME is specified as (HIGH LOW . IGNORED), as returned by 
`current-time' or `file-attributes'. The obsolete form (HIGH . LOW) 
is also still accepted. 
The third, optional, argument UNIVERSAL, if non-nil, means describe TIME 
as Universal Time; nil means describe TIME in the local time zone. 
The value is a copy of FORMAT-STRING, but with certain constructs replaced 
by text that describes the specified date and time in TIME: 

%Y is the year, %y within the century, %C the century. 
%G is the year corresponding to the ISO week, %g within the century. 
%m is the numeric month. 
%b and %h are the locale's abbreviated month name, %B the full name. 
%d is the day of the month, zero-padded, %e is blank-padded. 
%u is the numeric day of week from 1 (Monday) to 7, %w from 0 (Sunday) to 6. 
%a is the locale's abbreviated name of the day of week, %A the full name. 
%U is the week number starting on Sunday, %W starting on Monday, 
%V according to ISO 8601. 
%j is the day of the year. 

%H is the hour on a 24-hour clock, %I is on a 12-hour clock, %k is like %H 
only blank-padded, %l is like %I blank-padded. 
%p is the locale's equivalent of either AM or PM. 
%M is the minute. 
%S is the second. 
%N is the nanosecond, %6N the microsecond, %3N the millisecond, etc. 
%Z is the time zone name, %z is the numeric form. 
%s is the number of seconds since 1970-01-01 00:00:00 +0000. 

%c is the locale's date and time format. 
%x is the locale's "preferred" date format. 
%D is like "%m/%d/%y". 

%R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p". 
%X is the locale's "preferred" time format. 

Finally, %n is a newline, %t is a tab, %% is a literal %. 

Certain flags and modifiers are available with some format controls. 
The flags are `_', `-', `^' and `#'. For certain characters X, 
%_X is like %X, but padded with blanks; %-X is like %X, 
but without padding. %^X is like %X, but with all textual 
characters up-cased; %#X is like %X, but with letter-case of 
all textual characters reversed. 
%NX (where N stands for an integer) is like %X, 
but takes up at least N (a number) positions. 
The modifiers are `E' and `O'. For certain characters X, 
%EX is a locale's alternative version of %X; 
%OX is like %X, but uses the locale's number symbols. 

For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". 
+0

干杯好友... – Daniel 2012-07-21 19:32:57

相关问题