~ubuntu-branches/ubuntu/intrepid/swfdec0.6/intrepid

« back to all changes in this revision

Viewing changes to swfdec/swfdec_as_date.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Garcia Mantinan
  • Date: 2008-07-29 23:30:05 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729233005-k05tu7pnfyb8vcog
Tags: 0.6.8-1
* New upstream version. Fixes several crashes.
* Setting urgency as high to try to get all these fixes to lenny.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
#define IS_LEAP(year) (swfdec_as_date_days_in_year ((year)) == 366)
104
104
 
105
105
static double
106
 
swfdec_as_date_days_since_utc_for_year (int year)
 
106
swfdec_as_date_days_since_utc_for_year (double year)
107
107
{
108
 
  double year_big = year;
109
 
 
110
 
  return (
111
 
      365 * (year_big - 1970) +
112
 
      floor (((year_big - 1969) / 4.0f)) -
113
 
      floor (((year_big - 1901) / 100.0f)) +
114
 
      floor (((year_big - 1601) / 400.0f))
 
108
  return floor (
 
109
      365 * (year - 1970) +
 
110
      floor (((year - 1969) / 4.0f)) -
 
111
      floor (((year - 1901) / 100.0f)) +
 
112
      floor (((year - 1601) / 400.0f))
115
113
    );
116
114
}
117
115
 
118
 
static int
 
116
static double
119
117
swfdec_as_date_days_from_utc_to_year (double days)
120
118
{
121
 
  int low, high, pivot;
 
119
  double low, high, pivot;
122
120
 
123
121
  low = floor ((days >= 0 ? days / 366.0 : days / 365.0)) + 1970;
124
122
  high = ceil ((days >= 0 ? days / 365.0 : days / 366.0)) + 1970;
125
123
 
126
124
  while (low < high) {
127
 
    pivot = ((double)low + (double)high) / 2.0;
 
125
    pivot = floor ((low + high) / 2.0);
128
126
 
129
127
    if (swfdec_as_date_days_since_utc_for_year (pivot) <= days) {
130
128
      if (swfdec_as_date_days_since_utc_for_year (pivot + 1) > days) {
145
143
    BrokenTime *brokentime)
146
144
{
147
145
  double remaining;
148
 
  int year;
 
146
  double year;
149
147
 
150
148
  g_assert (brokentime != NULL);
151
149
 
555
553
  SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
556
554
 
557
555
  if (!swfdec_as_date_is_valid (date)) {
558
 
    SWFDEC_AS_VALUE_SET_STRING (ret, "Invalid Date");
 
556
    SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_Invalid_Date);
559
557
    return;
560
558
  }
561
559