Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit029ce56

Browse files
tzdb.cpp: Fall back to numeric offset when the current code page cannot represent the time zone short ID (#5558)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
1 parent343e96e commit029ce56

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎stl/src/tzdb.cpp‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,31 @@ void __stdcall __std_tzdb_delete_current_zone(__std_tzdb_current_zone_info* cons
567567

568568
_Info->_Abbrev =_Allocate_wide_to_narrow(_Abbrev.get(), _Abbrev_len, _Info->_Err);
569569
if (_Info->_Abbrev ==nullptr) {
570-
return_Propagate_error(_Info);
570+
constauto _Abs_offset = _Info->_Offset <0 ? -_Info->_Offset : _Info->_Offset;
571+
constauto _Offset_in_minutes = _Abs_offset / (60 *1000);
572+
constauto _Hours = _Offset_in_minutes /60;
573+
constauto _Mins = _Offset_in_minutes %60;
574+
575+
_STD unique_ptr<char[]> _Fallback_abbrev{new (_STD nothrow)char[_Mins ==0 ?4 :6]};
576+
577+
if (_Fallback_abbrev ==nullptr) {
578+
returnnullptr;
579+
}
580+
581+
_Fallback_abbrev[0] = _Info->_Offset <0 ?'-' :'+';
582+
_Fallback_abbrev[1] =static_cast<char>('0' + _Hours /10);
583+
_Fallback_abbrev[2] =static_cast<char>('0' + _Hours %10);
584+
585+
if (_Mins ==0) {
586+
_Fallback_abbrev[3] ='\0';
587+
}else {
588+
_Fallback_abbrev[3] =static_cast<char>('0' + _Mins /10);
589+
_Fallback_abbrev[4] =static_cast<char>('0' + _Mins %10);
590+
_Fallback_abbrev[5] ='\0';
591+
}
592+
593+
_Info->_Err = __std_tzdb_error::_Success;
594+
_Info->_Abbrev = _Fallback_abbrev.release();
571595
}
572596

573597
return _Info.release();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp