PR_NormalizeTime 编辑

Adjusts the fields of a clock/calendar time to their proper ranges, using a callback function.

Syntax

#include <prtime.h>

void PR_NormalizeTime (
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRExplodedTime *time,
  PRTimeParamFn params);

Parameters

The function has these parameters:

time
A pointer to a clock/calendar time in the /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRExplodedTime format.
params
A time parameter callback function.

Returns

Nothing; the time parameter is altered by the callback function.

Description

This function adjusts the fields of the specified time structure using the specified time parameter callback function, so that they are in the proper range.

Call this function in these situations:

  • To normalize a time after performing arithmetic operations directly on the field values of the calendar time object. For example, if you have a ] object that represents the date 3 March 1998 and you want to say "forty days from 3 March 1998", you can simply add 40 to the tm_mday field and then call PR_NormalizeTime().
  • To calculate the optional field values tm_wday and tm_yday. For example, suppose you want to compute the day of week for 3 March 1998. You can set tm_mday to 3, tm_month to 2, and tm_year to 1998, and all the other fields to 0, then call PR_NormalizeTime() with /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GMTParameters. On return, tm_wday (and tm_yday) are set for you.
  • To convert from one time zone to another. For example, if the input argument time is in time zone A and the input argument params represents time zone B, when PR_NormalizeTime() returns, time will be in time zone B.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:97 次

字数:2554

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文