~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/src/misc/prtime.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-06-16 11:28:24 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616112824-cg6qzhvt63lx7bub
Tags: 4.7.5-0ubuntu1
* New upstream version: 4.7.5 (LP: #387745)

* adjust patches to changed upstream code base
  - update debian/patches/99_configure.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
#include <string.h>
52
52
#include <ctype.h>
53
 
 
54
 
#ifdef XP_MAC
 
53
#include <errno.h>  /* for EINVAL */
55
54
#include <time.h>
56
 
#endif
57
55
 
58
56
/* 
59
57
 * The COUNT_LEAPS macro counts the number of leap years passed by
519
517
 *-------------------------------------------------------------------------
520
518
 */
521
519
 
522
 
#include <time.h>
523
 
 
524
520
#if defined(HAVE_INT_LOCALTIME_R)
525
521
 
526
522
/*
1573
1569
        result->tm_year = year;
1574
1570
  if (dotw != TT_UNKNOWN)
1575
1571
        result->tm_wday = (((int)dotw) - ((int)TT_SUN));
 
1572
  /*
 
1573
   * Mainly to compute wday and yday, but normalized time is also required
 
1574
   * by the check below that works around a Visual C++ 2005 mktime problem.
 
1575
   */
 
1576
  PR_NormalizeTime(result, PR_GMTParameters);
 
1577
  /* The remaining work is to set the gmt and dst offsets in tm_params. */
1576
1578
 
1577
1579
  if (zone == TT_UNKNOWN && default_to_gmt)
1578
1580
        {
1622
1624
                     date you are handing it is in daylight savings mode or not;
1623
1625
                     and if you're wrong, it will "fix" it for you. */
1624
1626
                  localTime.tm_isdst = -1;
 
1627
 
 
1628
#if _MSC_VER == 1400  /* 1400 = Visual C++ 2005 (8.0) */
 
1629
                  /*
 
1630
                   * mktime will return (time_t) -1 if the input is a date
 
1631
                   * after 23:59:59, December 31, 3000, US Pacific Time (not
 
1632
                   * UTC as documented): 
 
1633
                   * http://msdn.microsoft.com/en-us/library/d1y53h2a(VS.80).aspx
 
1634
                   * But if the year is 3001, mktime also invokes the invalid
 
1635
                   * parameter handler, causing the application to crash.  This
 
1636
                   * problem has been reported in
 
1637
                   * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266036.
 
1638
                   * We avoid this crash by not calling mktime if the date is
 
1639
                   * out of range.  To use a simple test that works in any time
 
1640
                   * zone, we consider year 3000 out of range as well.  (See
 
1641
                   * bug 480740.)
 
1642
                   */
 
1643
                  if (result->tm_year >= 3000) {
 
1644
                      /* Emulate what mktime would have done. */
 
1645
                      errno = EINVAL;
 
1646
                      secs = (time_t) -1;
 
1647
                  } else {
 
1648
                      secs = mktime(&localTime);
 
1649
                  }
 
1650
#else
1625
1651
                  secs = mktime(&localTime);
 
1652
#endif
1626
1653
                  if (secs != (time_t) -1)
1627
1654
                    {
1628
1655
                      PRTime usecs64;
1644
1671
                              + 1440 * (localTime.tm_mday - 2);
1645
1672
        }
1646
1673
 
1647
 
  /* mainly to compute wday and yday */
1648
 
  PR_NormalizeTime(result, PR_GMTParameters);
1649
1674
  result->tm_params.tp_gmt_offset = zone_offset * 60;
1650
1675
  result->tm_params.tp_dst_offset = dst_offset * 60;
1651
1676