wanghaisheng / fhir-cn

FHIR中文版 the Chinese translation of FHIR
https://github.com/FHIR-CN/fhir-spec-ZhCN
73 stars 23 forks source link

日期时间类数据类型 #36

Open wanghaisheng opened 9 years ago

wanghaisheng commented 9 years ago

http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14

date-fullyear = 4DIGIT date-month = 2DIGIT ; 01-12 date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on ; month/year time-hour = 2DIGIT ; 00-23 time-minute = 2DIGIT ; 00-59 time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second ; rules time-secfrac = "." 1*DIGIT time-numoffset = ("+" / "-") time-hour ":" time-minute time-offset = "Z" / time-numoffset

partial-time = time-hour ":" time-minute ":" time-second [time-secfrac] full-date = date-fullyear "-" date-month "-" date-mday full-time = partial-time time-offset

date-time = full-date "T" full-time

wanghaisheng commented 9 years ago
名称 FHIR XML SCHMEA Swagger RFC3339
date date xs:xs:gYear, xs:gYearMonth, xs:date date full-date
dateTime dateTime xs:xs:gYear, xs:gYearMonth, xs:date, xs:dateTime dateTime date-time
instant instant xs:dateTime dateTime date-time
wanghaisheng commented 9 years ago

Going ISO->FHIR - 8601 specifies a whole bunch of other forms what wouldn’t be considered valid in FHIR. E.g. year-week_number-day, year-day_of_year, etc. There are probably lots of good libraries for parsing ISO8601 in whatever your language of choice is. Going FHIR->ISO - If you have a FHIR date/datetime/instant, you basically already have a valid ISO8601 string. The only exception is that ISO8601 doesn’t talk about milliseconds so depending on what you’re doing you might want to drop that.

wanghaisheng commented 9 years ago

ISO8601, FHIR uses the XSD date/time strings, which are a specific restriction on what ISO8601 specifies. So in other words FHIR is ISO8601 compliant, but something ISO8601 compliant isn’t necessarily FHIR compliant.

wanghaisheng commented 9 years ago

instant 其实是精确到秒的 带时区的系统时间 timestamp 是标准化到utc的时间戳 http://tool.chinaz.com/Tools/unixtime.aspx

wanghaisheng commented 9 years ago

Unix 时间戳是为了纪念 Unix 系统 1970 年生日,而将格林尼治时间 1970 年 1 月 1 日 0 点 0 分 0 秒 定义为整数 0,此后 每过一秒则该整数加 1,而 1970 年 1 月 1 日以前的时间则定义为负值。因此 Unix 时间与 Windows 时间换算的方法也很 简单,知道了 Unix 时间定义的 0 值到现在过了多少秒,再折算为分钟、小时、天、月、年,以 1970 年 1 月 1 日 00:00:00 为基准累加,就换算出了当前的 Windows 时间了。而 Windows 时间换算 Unix 时间则正好相反。

wanghaisheng commented 9 years ago

wanghaisheng在15/4/19的下午3:51输入:

if i want to know all the resource created between  2014-07-29T16:53:10  and  2014-07-29T17:53:10,how could I know time zone which  the server`s system time  carries?if query param carries my local time zone ,could the server translate it into their timezone automatically?