Skip to content

Enhance localtime_s documentation on compatibility#5918

Open
Pawwz85 wants to merge 2 commits intoMicrosoftDocs:mainfrom
Pawwz85:main
Open

Enhance localtime_s documentation on compatibility#5918
Pawwz85 wants to merge 2 commits intoMicrosoftDocs:mainfrom
Pawwz85:main

Conversation

@Pawwz85
Copy link
Copy Markdown

@Pawwz85 Pawwz85 commented Apr 20, 2026

Clarified compatibility issues of localtime_s with C standard and provided guidance for enabling the standard-conforming variant.

Clarified compatibility issues of localtime_s with C standard and provided guidance for enabling the standard-conforming variant.
@prmerger-automator
Copy link
Copy Markdown
Contributor

@Pawwz85 : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit edc9a11:

✅ Validation status: passed

File Status Preview URL Details
docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md ✅Succeeded

For more details, please refer to the build report.

@v-regandowner
Copy link
Copy Markdown
Contributor

@TylerMSFT

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator Bot added the aq-pr-triaged Tracking label for the PR review team label Apr 21, 2026
Copy link
Copy Markdown
Collaborator

@TylerMSFT TylerMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we modify this slightly. As written, someone might think the behavior is different.
Something like: The Microsoft-specific localtime_s has a different signature than the C standard version. To enable the standard-conforming variant, define _CRT_USE_CONFORMING_ANNEX_K_TIME to a nonzero value before including <time.h>.

@Pawwz85
Copy link
Copy Markdown
Author

Pawwz85 commented Apr 22, 2026

@TylerMSFT Thanks for reviewing my pull request and providing feedback. I added clarification you suggested and decided to sneak in simillar remark for gmtime_s since _CRT_USE_CONFORMING_ANNEX_K_TIME touches it too.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 3ddbd60:

✅ Validation status: passed

File Status Preview URL Details
docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md ✅Succeeded
docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md ✅Succeeded

For more details, please refer to the build report.

@Pawwz85
Copy link
Copy Markdown
Author

Pawwz85 commented Apr 22, 2026

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Collaborator

@TylerMSFT TylerMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tweak. Thank you for catching the other one as well.

> The target environment should try to determine whether daylight saving time is in effect.

The Microsoft-specific **`localtime_s`** has a different signature than the C standard version. To enable the standard-conforming variant, define **`_CRT_USE_CONFORMING_ANNEX_K_TIME`** to a nonzero value before including any of the required headers.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"any of the required headers" is so vague that we may as well not say anything. Since it's only defined in <time.h>, let's call out which one we are talking about. Yes, there could be other headers that pull in <time.h>, but since that's the one that matters, let's call it out.


**`_gmtime64_s`**, which uses the **`__time64_t`** structure, allows dates to be expressed up through 23:59:59, December 31, 3000, UTC; whereas **`gmtime32_s`** only represent dates through 23:59:59 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for both these functions.

The Microsoft-specific **`gmtime_s`** has a different signature than the C standard version. To enable the standard-conforming variant, define **`_CRT_USE_CONFORMING_ANNEX_K_TIME`** to a nonzero value before including any of the required headers.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"any of the required headers" is so vague that we may as well not say anything. Since it's only defined in <time.h>, let's call out which one we are talking about. Yes, there could be other headers that pull in <time.h>, but since that's the one that matters, let's call it out.

@v-dirichards
Copy link
Copy Markdown
Contributor

v-dirichards commented Apr 22, 2026

@Pawwz85 Can you respond to the requested changes or let us know if you would like us to commit them?

@TylerMSFT - When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants