From: Steven R. L. <sr...@ic...> - 2016-07-28 16:25:50
|
Thanks. Would you mind filing a bug report? El [FECHA], "[NOMBRE]" <[DIRECCIÓN]> escribió: I've found what seems to be a workaround... UDate ToICUDate(const DateTime& DateTime) { //const int64 UNIXTimestamp = DateTime.ToUnixTimestamp(); //return static_cast<double>(UNIXTimestamp) * U_MILLIS_PER_SECOND; UErrorCode ICUStatus = U_ZERO_ERROR; icu::GregorianCalendar GregCal(ICUStatus); GregCal.setTimeZone(icu::TimeZone::getUnknown()); int32 Year, Month, Day; DateTime.GetDate(Year, Month, Day); GregCal.set(Year, Month - 1, Day, DateTime.GetHour(), DateTime.GetMinute(), DateTime.GetSecond()); return GregCal.getTime(ICUStatus); } The commented out code at the top is how we used to convert to a UDate (via a timestamp), however if I instead marshal the time through a icu::GregorianCalendar instance, I get back the UDate that ICU is expecting and pre-Georgian dates seemingly format correctly (even without having to change the calendar used by the icu::DateFormat). I'm not terribly happy with this as a solution though, and I'd still like to know why the timestamp method is having issues as I don't believe our representation of time is that unusual. -Jamie. On 28 July 2016 at 00:49, Jamie Dale <jam...@gm...> wrote: FWIW, before asking here I did try and search through the mailing list, and this post from 2006 kept cropping up: https://sourceforge.net/p/icu/mailman/message/12529106/ This is strikingly similar to what I'm seeing (1st Jan 0001 is 2 days off - I get 3rd Jan 0001), but given this is from 2006, surely it's been fixed by now? -Jamie. On 27 July 2016 at 23:40, Jamie Dale <jam...@gm...> wrote: Hey all, I'm investigating an issue where pre-Gregorian dates are failing to format correctly with icu::DateFormat. We're using ICU 53, and our internal concept of time is ticks of 0.1 microseconds since 1st January 0001 - we convert this to a UNIX timestamp and multiply by U_MILLIS_PER_SECOND before passing it to ICU as a UDate. At first I thought this might be due to the Gregorian switch-over, so I tried constructing my own icu::GregorianCalendar, setting the Gregorian change date to 1st January 0001, and then letting the icu::DateFormat adopt that as its calendar, however it didn't seem to make any difference (my calendar reports U_USING_FALLBACK_WARNING when being constructed... I'm not sure why). I'm wondering if anyone else has seen this issue, or whether anyone has any advice? Thanks, Jamie. ------------------------------------------------------------------------------ _______________________________________________ icu-support mailing list - icu...@li... To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-support Archives/Project Info: http://site.icu-project.org/contacts |