浏览代码

docs: update date-fns-extra comment

shijia.me 2 年之前
父节点
当前提交
9f83730b0f
共有 1 个文件被更改,包括 10 次插入9 次删除
  1. 10 9
      packages/semi-foundation/utils/date-fns-extra.ts

+ 10 - 9
packages/semi-foundation/utils/date-fns-extra.ts

@@ -117,10 +117,11 @@ const format = (date: number | Date, formatToken: string, options?: any) => {
  * 
  * @example
  * ```javascript
- * import { zonedTimeToUtc } from 'date-fns-tz'
- * const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone
- * const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles
- * const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC
+ * import { utcToZonedTime } from 'date-fns-tz'
+ * const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York
+ * const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00)
+ * renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone)
+ * renderTimeZoneSelect(timeZone) // America/New_York
  * ```
  * 
  * @see https://github.com/marnusw/date-fns-tz#zonedtimetoutc
@@ -132,11 +133,11 @@ const utcToZonedTime = (date: string | number | Date, timeZone: string | number,
  * 
  * @example
  * ```
- * import { utcToZonedTime } from 'date-fns-tz'
- * const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York
- * const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00)
- * renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone)
- * renderTimeZoneSelect(timeZone) // America/New_York
+ * import { zonedTimeToUtc } from 'date-fns-tz'
+ * const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone)
+ * const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles
+ * const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC
+ * postToServer(utcDate.toISOString(), timeZone) // post 2014-06-25T17:00:00.000Z, America/Los_Angeles
  * ```
  * 
  * @see https://github.com/marnusw/date-fns-tz#utctozonedtime