// performs a locale sensitive date formatting operation on the PRExplodedTime parameter nsresult nsDateTimeFormatUnix::FormatPRExplodedTime(nsILocale* locale, const nsDateFormatSelector dateFormatSelector, const nsTimeFormatSelector timeFormatSelector, const PRExplodedTime* explodedTime, nsAString& stringOut) { struct tm tmTime; /* be safe and set all members of struct tm to zero * * there are other fields in the tm struct that we aren't setting * (tm_isdst, tm_gmtoff, tm_zone, should we set these?) and since * tmTime is on the stack, it may be filled with garbage, but * the garbage may vary. (this may explain why some saw bug #10412, and * others did not. * * when tmTime is passed to strftime() with garbage bad things may happen. * see bug #10412 */ memset( &tmTime, 0, sizeof(tmTime) ); tmTime.tm_yday = explodedTime->tm_yday; tmTime.tm_wday = explodedTime->tm_wday; tmTime.tm_year = explodedTime->tm_year; tmTime.tm_year -= 1900; tmTime.tm_mon = explodedTime->tm_month; tmTime.tm_mday = explodedTime->tm_mday; tmTime.tm_hour = explodedTime->tm_hour; tmTime.tm_min = explodedTime->tm_min; tmTime.tm_sec = explodedTime->tm_sec; return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut); }
// performs a locale sensitive date formatting operation on the time_t parameter nsresult nsDateTimeFormatWin::FormatTime(nsILocale* locale, const nsDateFormatSelector dateFormatSelector, const nsTimeFormatSelector timeFormatSelector, const time_t timetTime, nsAString& stringOut) { return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime( &timetTime ), stringOut); }
// performs a locale sensitive date formatting operation on the time_t parameter nsresult nsDateTimeFormatMac::FormatTime(nsILocale* locale, const nsDateFormatSelector dateFormatSelector, const nsTimeFormatSelector timeFormatSelector, const time_t timetTime, nsAString& stringOut) { struct tm tmTime; return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime_r(&timetTime, &tmTime), stringOut); }
nsresult nsDateTimeFormatUnix::FormatTime(nsILocale* locale, const nsDateFormatSelector dateFormatSelector, const nsTimeFormatSelector timeFormatSelector, const time_t timetTime, nsAString& stringOut) { struct tm tmTime; memcpy(&tmTime, localtime(&timetTime), sizeof(struct tm)); return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut); }
/*static*/ nsresult DateTimeFormat::FormatTime(const nsDateFormatSelector aDateFormatSelector, const nsTimeFormatSelector aTimeFormatSelector, const time_t aTimetTime, nsAString& aStringOut) { struct tm tmTime; memcpy(&tmTime, localtime(&aTimetTime), sizeof(struct tm)); return FormatTMTime(aDateFormatSelector, aTimeFormatSelector, &tmTime, aStringOut); }
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter nsresult nsDateTimeFormatMac::FormatPRExplodedTime(nsILocale* locale, const nsDateFormatSelector dateFormatSelector, const nsTimeFormatSelector timeFormatSelector, const PRExplodedTime* explodedTime, nsAString& stringOut) { struct tm tmTime; memset( &tmTime, 0, sizeof(tmTime) ); tmTime.tm_yday = explodedTime->tm_yday; tmTime.tm_wday = explodedTime->tm_wday; tmTime.tm_year = explodedTime->tm_year; tmTime.tm_year -= 1900; tmTime.tm_mon = explodedTime->tm_month; tmTime.tm_mday = explodedTime->tm_mday; tmTime.tm_hour = explodedTime->tm_hour; tmTime.tm_min = explodedTime->tm_min; tmTime.tm_sec = explodedTime->tm_sec; return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut); }