INFORMATION FOR DEVELOPERS
Once the Date API is installed, all functions in the API are available to be used
anywhere by any module. If the Date Timezone module is installed, the system site
timezone selector and the user timezone selectors are overwritten to allow the
selection of timezone names instead of offsets. Proper timezone conversion
requires knowledge of those timezone names, something that is not currently
available in Drupal core, and the change in selectors makes it possible to track it.
In most cases, you should enable the Date Timezone module any time you use the
Date API to be able to set the site and user timezone names. It is not enabled by
default in case another module is setting timezone names in the database.
The API uses the PHP 5.2 date functions to create and manipulate dates, and
contains an option module that will emulate those functions in earlier versions
of PHP.
If you are using PHP 4 or PHP 5.0 or 5.1, native date handling won't work right.
Install the Date_PHP4 module to enable wrapper functions so this code will work
in old PHP versions.
Example, the following will create a date for the local value in one
timezone, adjust it to a different timezone, then return the offset in seconds
in the new timezone for the input date; The offset will be adjusted for both
the timezone difference and daylight savings time, if necessary:
$date = date_create('2007-03-11 02:00:00', timezone_open('America/Chicago'));
$chicago_time = date_format('Y-m-d H:i', $date);
print 'At '. $chicago_time .' in Chicago, the timezone offset in seconds
was '. date_offset_get($date);
date_timezone_set($date, timezone_open('Europe/Berlin');
$berlin_time = date_format($date, 'Y-m-d H:i');
print 'It was '. $berlin_time .' in Berlin when it
was '. $chicago_time .' in Chicago.';
print 'At that time in Berlin, the timezone offset in seconds was
'. date_offset_get($date);
A helper function is available, date_make_date($string, $timezone, $type),
where $string is a unixtimestamp, an ISO date, or a string like YYYY-MM-DD HH:MM:SS,
$timezone is the name of the timezone this date is in, and $type is the type
of date it is (DATE_UNIX, DATE_ISO, or DATE_DATETIME). It create and return
a date object set to the right date and timezone.
Simpletest tests for these functions are included in the package.
Available functions include the following (more documentation is provided in
the files):
============================================================================
Date PHP4 Module
============================================================================
PHP 4 substitutions for the PHP 5 date functions are supplied. Use the PHP 5
functions in your code as they would normally be used and the PHP 4
alternatives will be automatically be substituted in when needed.
You cannot do everything with these functions that can be done in PHP 5, but
you can create dates, find timezone offsets, and format the results.
Timezone handling uses native PHP 5 functions when available and degrades
automatically for PHP 4 to use substitutions like those
provided in previous versions of the Date and Event modules.
Read the doxygen documentation in this module for more information
about using the functions in ways that will work in PHP 4.
Simpletest tests for the PHP 4 equivalent functions are included in the package.
The following functions are emulated in PHP4:
date_create()
date_date_set()
date_format()
date_offset_get()
date_timezone_set()
timezone_abbreviations_list()
timezone_identifiers_list()
timezone_offset_get()
timezone_open()
============================================================================
Preconfigured arrays
============================================================================
Both translated and untranslated values are available. The date_week_days_ordered()
function will shift an array of week day names so it starts with the site's
first day of the week, otherwise the weekday names start with Sunday as the first
value, the expected order for many php and sql functions.
date_month_names();
date_month_names_abbr();
date_month_names_untranslated();
date_week_days();
date_week_days_abbr();
date_week_days_untranslated();
date_week_days_ordered();
date_years();
date_hours();
date_minutes();
date_seconds();
date_timezone_names();
date_ampm();
============================================================================
Miscellaneous date manipulation functions
============================================================================
Pre-defined constants and functions that will handle pre-1970 and post-2038
dates in both PHP 4 and PHP 5, in any OS. Dates can be converted from one
type to another and date parts can be extracted from any date type.
DATE_DATETIME
DATE_ISO
DATE_UNIX
DATE_ARRAY
DATE_OBJECT
DATE_ICAL
date_convert()
date_is_valid();
date_part_is_valid();
date_part_extract();
============================================================================
Date calculation and navigation
============================================================================
date_diff() will find the time difference between any two days, measured
in seconds, minutes, hours, days, months, weeks, or years.
date_days_in_month();
date_days_in_year();
date_weeks_in_year();
date_last_day_of_month();
date_day_of_week();
date_day_of_week_name();
date_diff();
============================================================================
Date regex and format helpers
============================================================================
Pre-defined constants, an array of date format strings and their
equivalent regex strings.
DATE_REGEX_LOOSE is a very loose regex that will pull date parts out
of an ISO date with or without separators, using either 'T' or a space
to separate date and time, and with or without time.
date_format_date() is similar to format_date(), except it takes a
date object instead of a timestamp as the first parameter.
DATE_FORMAT_ISO
DATE_FORMAT_DATETIME
DATE_FORMAT_UNIX
DATE_FORMAT_ICAL
DATE_REGEX_ISO
DATE_REGEX_DATETIME
DATE_REGEX_LOOSE
date_format_date();
date_t()
date_short_formats();
date_medium_formats();
date_long_formats();
date_format_patterns();
============================================================================
Standardized ical parser and creator
============================================================================
The iCal parser is found in date_api_ical.inc, which is not included by default.
Include that file if you want to use these functions:
Complete rewrite of ical imports to parse vevents, vlocations, valarms,
and all kinds of timezone options and repeat rules for ical imports.
The function now sticks to parsing the ical into an array that can be used
in various ways. It no longer trys to convert timezones while parsing,
instead a date_ical_date_format() function is provided that can be used to
convert from the ical timezone to whatever timezone is desired in the
results. Repeat rules are parsed into an array which other modules can
manipulate however they like to create additional events from the results.
date_ical_export();
date_ical_import();
date_ical_date_format();
============================================================================
Helpers for portable date SQL
============================================================================
The SQL functions are found in date_api_sql.inc, which is not included by default.
Include that file if you want to use these functions:
date_sql();
date_server_zone_adj();
date_sql_concat();
date_sql_pad();
============================================================================
Date forms and validators
============================================================================
Reusable, configurable, self-validating FAPI date elements are found in
date_api_elements.inc, which is not included by default. Include it
if you want to use these elements. To use them, create a form element
没有合适的资源?快使用搜索试试~ 我知道了~
using drupal源代码
共2000个文件
png:567个
inc:494个
js:281个
4星 · 超过85%的资源 需积分: 10 22 下载量 6 浏览量
2011-03-08
16:31:06
上传
评论 1
收藏 14.6MB ZIP 举报
温馨提示
drupal,using drupal,PHP,源代码, 配套原书,不可多得
资源推荐
资源详情
资源评论
收起资源包目录
using drupal源代码 (2000个子文件)
fckeditor.afp 4KB
sample02.afp 3KB
sample04.afp 3KB
sample03.afp 3KB
sampleposteddata.afp 2KB
sample01.afp 2KB
fck.afpa 25B
config.ascx 5KB
class_upload.asp 10KB
io.asp 7KB
fckeditor.asp 6KB
commands.asp 6KB
config.asp 6KB
sample02.asp 3KB
sample04.asp 3KB
sample03.asp 3KB
connector.asp 2KB
sample01.asp 2KB
upload.asp 2KB
basexml.asp 2KB
sampleposteddata.asp 2KB
util.asp 1KB
connector.aspx 1KB
upload.aspx 1KB
package.bat 893B
run.bat 811B
image.cfc 46KB
ImageObject.cfc 12KB
fckeditor.cfc 9KB
cf5_upload.cfm 11KB
cf5_connector.cfm 10KB
cf_io.cfm 10KB
cf_commands.cfm 8KB
config.cfm 8KB
fckeditor.cfm 7KB
spellchecker.cfm 5KB
cf_util.cfm 4KB
sample02_mx.cfm 3KB
sample04_mx.cfm 3KB
sample02.cfm 3KB
sample03_mx.cfm 3KB
sample04.cfm 3KB
cf_connector.cfm 3KB
sample03.cfm 3KB
cf_basexml.cfm 3KB
fckutils.cfm 2KB
cf_upload.cfm 2KB
sample01_mx.cfm 2KB
sample01.cfm 2KB
sampleposteddata.cfm 2KB
connector.cfm 1005B
upload.cfm 993B
sample02.cgi 5KB
sample04.cgi 5KB
sample03.cgi 5KB
connector.cgi 4KB
sample01.cgi 3KB
upload.cgi 3KB
sampleposteddata.cgi 3KB
russia_643_1.cif 6KB
philippines_608_2.cif 6KB
united_kingdom_826_1.cif 6KB
italy_380_1.cif 5KB
thailand_764_1.cif 5KB
france_250_1.cif 4KB
greece_300_1.cif 3KB
lithuania_440_1.cif 3KB
spain_724_1.cif 3KB
united_states_840_1.cif 3KB
greenland_304_1.cif 3KB
taiwan_158_1.cif 3KB
egypt_818_1.cif 3KB
latvia_428_1.cif 3KB
india_356_1.cif 3KB
afghanistan_4_1.cif 3KB
mexico_484_1.cif 3KB
japan_392_1.cif 3KB
switzerland_756_1.cif 3KB
venezuela_862_1.cif 3KB
peru_604_1.cif 2KB
portugal_620_1.cif 2KB
sweden_752_1.cif 2KB
new_zealand_554_3.cif 2KB
dominican_republic_214_1.cif 2KB
china_156_1.cif 2KB
zimbabwe_716_1.cif 2KB
australia_36_2.cif 2KB
ireland_372_1.cif 2KB
ukraine_804_1.cif 2KB
israel_376_1.cif 2KB
indonesia_360_1.cif 2KB
romania_642_1.cif 2KB
austria_40_1.cif 2KB
south_africa_710_1.cif 2KB
costa_rica_188_1.cif 2KB
iran_364_1.cif 2KB
andorra_20_1.cif 2KB
korea_republic_of_410_1.cif 2KB
norway_578_1.cif 2KB
kazakhstan_398_1.cif 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- moqiang022013-12-26与电子书配套。
- 三昧真火-LZW2012-10-05与电子书配套,很好。
jier
- 粉丝: 32
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功