Re: [PATCH 1/4] jscript: Added implementation of Date constructor with more then one argument
Piotr Caban piotr.ca...@gmail.com writes: @@ -221,6 +253,62 @@ static inline DOUBLE week_day(DOUBLE time) return ret; } +static inline DOUBLE convert_time(int year, SYSTEMTIME st) +{ +DOUBLE time; +int set_week_day; + +time = time_from_year(year); +time += (DOUBLE)day_from_month(st.wMonth-1, in_leap_year(time)) * MS_PER_DAY; + +set_week_day = st.wDayOfWeek-week_day(time); +if(set_week_day 0) +set_week_day += 7; +time += set_week_day * MS_PER_DAY; + +time += (DOUBLE)(st.wDay-1) * 7 * MS_PER_DAY; +if(month_from_time(time) != st.wMonth-1) +time -= 7 * MS_PER_DAY; + +time += st.wHour * MS_PER_HOUR; +time += st.wMinute * MS_PER_MINUTE; + +return time; +} You should use SystemTimeToFileTime or some similar function, no need to reinvent the wheel. -- Alexandre Julliard julli...@winehq.org
Re: [PATCH 1/4] jscript: Added implementation of Date constructor with more then one argument
Alexandre Julliard wrote: Piotr Caban piotr.ca...@gmail.com writes: @@ -221,6 +253,62 @@ static inline DOUBLE week_day(DOUBLE time) return ret; } +static inline DOUBLE convert_time(int year, SYSTEMTIME st) +{ +DOUBLE time; +int set_week_day; + +time = time_from_year(year); +time += (DOUBLE)day_from_month(st.wMonth-1, in_leap_year(time)) * MS_PER_DAY; + +set_week_day = st.wDayOfWeek-week_day(time); +if(set_week_day 0) +set_week_day += 7; +time += set_week_day * MS_PER_DAY; + +time += (DOUBLE)(st.wDay-1) * 7 * MS_PER_DAY; +if(month_from_time(time) != st.wMonth-1) +time -= 7 * MS_PER_DAY; + +time += st.wHour * MS_PER_HOUR; +time += st.wMinute * MS_PER_MINUTE; + +return time; +} You should use SystemTimeToFileTime or some similar function, no need to reinvent the wheel. In this case SYSTEMTIME keeps information returned by GetTimeZoneInformation. It's used to store informations about daylight/standard time adjustment. Because there's no ordinary date SystemTimeToFileTime can't be used.
Re: [PATCH 1/4] jscript: Added implementation of Date constructor with more then one argument
Piotr Caban piotr.ca...@gmail.com writes: Alexandre Julliard wrote: You should use SystemTimeToFileTime or some similar function, no need to reinvent the wheel. In this case SYSTEMTIME keeps information returned by GetTimeZoneInformation. It's used to store informations about daylight/standard time adjustment. Because there's no ordinary date SystemTimeToFileTime can't be used. I see, that makes sense. You do need to check that the year is 0 though, because otherwise it's still a normal date format. -- Alexandre Julliard julli...@winehq.org