ReactOS  0.4.14-dev-342-gdc047f9
date.c File Reference
#include <limits.h>
#include <math.h>
#include <assert.h>
#include "jscript.h"
#include "wine/debug.h"
Include dependency graph for date.c:

Go to the source code of this file.

Classes

struct  DateInstance
 

Macros

#define TIME_EPOCH   ((ULONGLONG)(369 * 365 + 89) * 86400 * 1000)
 
#define MS_PER_DAY   86400000
 
#define MS_PER_HOUR   3600000
 
#define MS_PER_MINUTE   60000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static DateInstancedate_from_jsdisp (jsdisp_t *jsdisp)
 
static DateInstancedate_this (vdisp_t *jsthis)
 
static DOUBLE day (DOUBLE time)
 
static DOUBLE time_within_day (DOUBLE time)
 
static DOUBLE days_in_year (DOUBLE year)
 
static DOUBLE day_from_year (DOUBLE year)
 
static int day_from_month (int month, int in_leap_year)
 
static DOUBLE time_from_year (DOUBLE year)
 
static DOUBLE year_from_time (DOUBLE time)
 
static int in_leap_year (DOUBLE time)
 
static int day_within_year (DOUBLE time)
 
static DOUBLE month_from_time (DOUBLE time)
 
static DOUBLE date_from_time (DOUBLE time)
 
static DOUBLE week_day (DOUBLE time)
 
static DOUBLE convert_time (int year, SYSTEMTIME st)
 
static DOUBLE daylight_saving_ta (DOUBLE time, DateInstance *date)
 
static DOUBLE local_time (DOUBLE time, DateInstance *date)
 
static DOUBLE utc (DOUBLE time, DateInstance *date)
 
static DOUBLE hour_from_time (DOUBLE time)
 
static DOUBLE min_from_time (DOUBLE time)
 
static DOUBLE sec_from_time (DOUBLE time)
 
static DOUBLE ms_from_time (DOUBLE time)
 
static DOUBLE make_time (DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
 
static DOUBLE make_day (DOUBLE year, DOUBLE month, DOUBLE day)
 
static DOUBLE make_date (DOUBLE day, DOUBLE time)
 
static DOUBLE time_clip (DOUBLE time)
 
static double date_now (void)
 
static SYSTEMTIME create_systemtime (DOUBLE time)
 
static HRESULT date_to_string (DOUBLE time, BOOL show_offset, int offset, jsval_t *r)
 
static HRESULT dateobj_to_string (DateInstance *date, jsval_t *r)
 
static HRESULT Date_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toLocaleString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toISOString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_valueOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT create_utc_string (script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
 
static HRESULT Date_toUTCString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toGMTString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT dateobj_to_date_string (DateInstance *date, jsval_t *r)
 
static HRESULT Date_toDateString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toTimeString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toLocaleDateString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_toLocaleTimeString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getTime (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getFullYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCFullYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getMonth (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCMonth (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getDate (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCDate (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getDay (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCDay (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getHours (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCHours (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getMinutes (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCMinutes (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getSeconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCSeconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getMilliseconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getUTCMilliseconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getTimezoneOffset (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setTime (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setMilliseconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCMilliseconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setSeconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCSeconds (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setMinutes (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCMinutes (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setHours (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCHours (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setDate (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCDate (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setMonth (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCMonth (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setFullYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setUTCFullYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_getYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_setYear (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Date_get_value (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static HRESULT create_date (script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE time, jsdisp_t **ret)
 
static HRESULT date_parse (jsstr_t *input_str, double *ret)
 
static HRESULT DateConstr_parse (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT date_utc (script_ctx_t *ctx, unsigned argc, jsval_t *argv, double *ret)
 
static HRESULT DateConstr_UTC (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT DateConstr_now (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT DateConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT create_date_constr (script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
 

Variables

static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const WCHAR toLocaleStringW [] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}
 
static const WCHAR valueOfW [] = {'v','a','l','u','e','O','f',0}
 
static const WCHAR toISOStringW [] = {'t','o','I','S','O','S','t','r','i','n','g',0}
 
static const WCHAR toUTCStringW [] = {'t','o','U','T','C','S','t','r','i','n','g',0}
 
static const WCHAR toGMTStringW [] = {'t','o','G','M','T','S','t','r','i','n','g',0}
 
static const WCHAR toDateStringW [] = {'t','o','D','a','t','e','S','t','r','i','n','g',0}
 
static const WCHAR toTimeStringW [] = {'t','o','T','i','m','e','S','t','r','i','n','g',0}
 
static const WCHAR toLocaleDateStringW [] = {'t','o','L','o','c','a','l','e','D','a','t','e','S','t','r','i','n','g',0}
 
static const WCHAR toLocaleTimeStringW [] = {'t','o','L','o','c','a','l','e','T','i','m','e','S','t','r','i','n','g',0}
 
static const WCHAR getTimeW [] = {'g','e','t','T','i','m','e',0}
 
static const WCHAR getFullYearW [] = {'g','e','t','F','u','l','l','Y','e','a','r',0}
 
static const WCHAR getUTCFullYearW [] = {'g','e','t','U','T','C','F','u','l','l','Y','e','a','r',0}
 
static const WCHAR getMonthW [] = {'g','e','t','M','o','n','t','h',0}
 
static const WCHAR getUTCMonthW [] = {'g','e','t','U','T','C','M','o','n','t','h',0}
 
static const WCHAR getDateW [] = {'g','e','t','D','a','t','e',0}
 
static const WCHAR getUTCDateW [] = {'g','e','t','U','T','C','D','a','t','e',0}
 
static const WCHAR getDayW [] = {'g','e','t','D','a','y',0}
 
static const WCHAR getUTCDayW [] = {'g','e','t','U','T','C','D','a','y',0}
 
static const WCHAR getHoursW [] = {'g','e','t','H','o','u','r','s',0}
 
static const WCHAR getUTCHoursW [] = {'g','e','t','U','T','C','H','o','u','r','s',0}
 
static const WCHAR getMinutesW [] = {'g','e','t','M','i','n','u','t','e','s',0}
 
static const WCHAR getUTCMinutesW [] = {'g','e','t','U','T','C','M','i','n','u','t','e','s',0}
 
static const WCHAR getSecondsW [] = {'g','e','t','S','e','c','o','n','d','s',0}
 
static const WCHAR getUTCSecondsW [] = {'g','e','t','U','T','C','S','e','c','o','n','d','s',0}
 
static const WCHAR getMillisecondsW [] = {'g','e','t','M','i','l','l','i','s','e','c','o','n','d','s',0}
 
static const WCHAR getUTCMillisecondsW [] = {'g','e','t','U','T','C','M','i','l','l','i','s','e','c','o','n','d','s',0}
 
static const WCHAR getTimezoneOffsetW [] = {'g','e','t','T','i','m','e','z','o','n','e','O','f','f','s','e','t',0}
 
static const WCHAR setTimeW [] = {'s','e','t','T','i','m','e',0}
 
static const WCHAR setMillisecondsW [] = {'s','e','t','M','i','l','l','i','s','e','c','o','n','d','s',0}
 
static const WCHAR setUTCMillisecondsW [] = {'s','e','t','U','T','C','M','i','l','l','i','s','e','c','o','n','d','s',0}
 
static const WCHAR setSecondsW [] = {'s','e','t','S','e','c','o','n','d','s',0}
 
static const WCHAR setUTCSecondsW [] = {'s','e','t','U','T','C','S','e','c','o','n','d','s',0}
 
static const WCHAR setMinutesW [] = {'s','e','t','M','i','n','u','t','e','s',0}
 
static const WCHAR setUTCMinutesW [] = {'s','e','t','U','T','C','M','i','n','u','t','e','s',0}
 
static const WCHAR setHoursW [] = {'s','e','t','H','o','u','r','s',0}
 
static const WCHAR setUTCHoursW [] = {'s','e','t','U','T','C','H','o','u','r','s',0}
 
static const WCHAR setDateW [] = {'s','e','t','D','a','t','e',0}
 
static const WCHAR setUTCDateW [] = {'s','e','t','U','T','C','D','a','t','e',0}
 
static const WCHAR setMonthW [] = {'s','e','t','M','o','n','t','h',0}
 
static const WCHAR setUTCMonthW [] = {'s','e','t','U','T','C','M','o','n','t','h',0}
 
static const WCHAR setFullYearW [] = {'s','e','t','F','u','l','l','Y','e','a','r',0}
 
static const WCHAR setUTCFullYearW [] = {'s','e','t','U','T','C','F','u','l','l','Y','e','a','r',0}
 
static const WCHAR getYearW [] = {'g','e','t','Y','e','a','r',0}
 
static const WCHAR setYearW [] = {'s','e','t','Y','e','a','r',0}
 
static const WCHAR UTCW [] = {'U','T','C',0}
 
static const WCHAR nowW [] = {'n','o','w',0}
 
static const WCHAR parseW [] = {'p','a','r','s','e',0}
 
static const builtin_prop_t Date_props []
 
static const builtin_info_t Date_info
 
static const builtin_info_t DateInst_info
 
static const builtin_prop_t DateConstr_props []
 
static const builtin_info_t DateConstr_info
 

Macro Definition Documentation

◆ MS_PER_DAY

#define MS_PER_DAY   86400000

Definition at line 112 of file date.c.

◆ MS_PER_HOUR

#define MS_PER_HOUR   3600000

Definition at line 113 of file date.c.

◆ MS_PER_MINUTE

#define MS_PER_MINUTE   60000

Definition at line 114 of file date.c.

◆ TIME_EPOCH

#define TIME_EPOCH   ((ULONGLONG)(369 * 365 + 89) * 86400 * 1000)

Definition at line 36 of file date.c.

Function Documentation

◆ convert_time()

static DOUBLE convert_time ( int  year,
SYSTEMTIME  st 
)
inlinestatic

Definition at line 289 of file date.c.

290 {
291  DOUBLE time;
292  int set_week_day;
293 
294  if(st.wMonth == 0)
295  return NAN;
296 
297  if(st.wYear != 0)
298  year = st.wYear;
299 
300  time = time_from_year(year);
302 
303  if(st.wYear == 0) {
304  set_week_day = st.wDayOfWeek-week_day(time);
305  if(set_week_day < 0)
306  set_week_day += 7;
307  time += set_week_day * MS_PER_DAY;
308 
309  time += (DOUBLE)(st.wDay-1) * 7 * MS_PER_DAY;
310  if(month_from_time(time) != st.wMonth-1)
311  time -= 7 * MS_PER_DAY;
312  }
313  else
314  time += st.wDay * MS_PER_DAY;
315 
316  time += st.wHour * MS_PER_HOUR;
317  time += st.wMinute * MS_PER_MINUTE;
318 
319  return time;
320 }
#define DOUBLE(x)
Definition: atom.c:30
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
WORD wMonth
Definition: winbase.h:878
WORD wDayOfWeek
Definition: winbase.h:879
#define MS_PER_HOUR
Definition: date.c:113
__u16 time
Definition: mkdosfs.c:366
#define MS_PER_DAY
Definition: date.c:112
WORD wYear
Definition: winbase.h:877
WORD wMinute
Definition: winbase.h:882
#define MS_PER_MINUTE
Definition: date.c:114
static int day_from_month(int month, int in_leap_year)
Definition: date.c:159
#define NAN
Definition: misc.c:46
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
WORD wDay
Definition: winbase.h:880
WORD wHour
Definition: winbase.h:881
static DOUBLE time_from_year(DOUBLE year)
Definition: date.c:191
double DOUBLE
Definition: typedefs.h:68
static int in_leap_year(DOUBLE time)
Definition: date.c:215

Referenced by daylight_saving_ta().

◆ create_date()

static HRESULT create_date ( script_ctx_t ctx,
jsdisp_t object_prototype,
DOUBLE  time,
jsdisp_t **  ret 
)
static

Definition at line 2003 of file date.c.

2004 {
2005  DateInstance *date;
2006  HRESULT hres;
2008 
2009  GetTimeZoneInformation(&tzi);
2010 
2011  date = heap_alloc_zero(sizeof(DateInstance));
2012  if(!date)
2013  return E_OUTOFMEMORY;
2014 
2015  if(object_prototype)
2016  hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
2017  else
2018  hres = init_dispex_from_constr(&date->dispex, ctx, &DateInst_info, ctx->date_constr);
2019  if(FAILED(hres)) {
2020  heap_free(date);
2021  return hres;
2022  }
2023 
2024  date->time = time;
2025  date->bias = tzi.Bias;
2026  date->standardDate = tzi.StandardDate;
2027  date->standardBias = tzi.StandardBias;
2028  date->daylightDate = tzi.DaylightDate;
2029  date->daylightBias = tzi.DaylightBias;
2030 
2031  *ret = &date->dispex;
2032  return S_OK;
2033 }
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
__u16 time
Definition: mkdosfs.c:366
static const builtin_info_t DateInst_info
Definition: date.c:1995
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const builtin_info_t Date_info
Definition: date.c:1986
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
SYSTEMTIME StandardDate
Definition: winbase.h:1168
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
jsdisp_t * date_constr
Definition: jscript.h:445
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1030
SYSTEMTIME DaylightDate
Definition: winbase.h:1171
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_date_constr(), and DateConstr_value().

◆ create_date_constr()

HRESULT create_date_constr ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsdisp_t **  ret 
)

Definition at line 2534 of file date.c.

2535 {
2536  jsdisp_t *date;
2537  HRESULT hres;
2538 
2539  static const WCHAR DateW[] = {'D','a','t','e',0};
2540 
2541  hres = create_date(ctx, object_prototype, 0.0, &date);
2542  if(FAILED(hres))
2543  return hres;
2544 
2546  PROPF_CONSTR|7, date, ret);
2547 
2549  return hres;
2550 }
static const WCHAR DateW[]
Definition: global.c:38
static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE time, jsdisp_t **ret)
Definition: date.c:2003
#define PROPF_CONSTR
Definition: jscript.h:98
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:686
static const builtin_info_t DateConstr_info
Definition: date.c:2525
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: date.c:2436
int ret
__u16 date
Definition: mkdosfs.c:366
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268

Referenced by init_constructors().

◆ create_systemtime()

static SYSTEMTIME create_systemtime ( DOUBLE  time)
static

Definition at line 470 of file date.c.

471 {
472  SYSTEMTIME st;
473 
474  st.wYear = year_from_time(time);
475  st.wMonth = month_from_time(time) + 1;
476  st.wDayOfWeek = week_day(time);
477  st.wDay = date_from_time(time);
478  st.wHour = hour_from_time(time);
479  st.wMinute = min_from_time(time);
480  st.wSecond = sec_from_time(time);
482 
483  return st;
484 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
WORD wMonth
Definition: winbase.h:878
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
WORD wDayOfWeek
Definition: winbase.h:879
__u16 time
Definition: mkdosfs.c:366
WORD wYear
Definition: winbase.h:877
WORD wMinute
Definition: winbase.h:882
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
WORD wSecond
Definition: winbase.h:883
WORD wMilliseconds
Definition: winbase.h:884
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
WORD wDay
Definition: winbase.h:880
WORD wHour
Definition: winbase.h:881

Referenced by Date_toLocaleDateString(), Date_toLocaleString(), and Date_toLocaleTimeString().

◆ create_utc_string()

static HRESULT create_utc_string ( script_ctx_t ctx,
vdisp_t jsthis,
jsval_t r 
)
inlinestatic

Definition at line 700 of file date.c.

701 {
702  static const WCHAR formatADW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ',
703  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 };
704  static const WCHAR formatBCW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ','B','.','C','.',' ',
705  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 };
706 
707  static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1,
710  static const DWORD month_ids[] = { LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2,
716 
717  BOOL formatAD = TRUE;
718  WCHAR week[64], month[64];
719  WCHAR buf[192];
721  jsstr_t *date_str;
722  int year, day;
723  DWORD lcid_en;
724 
725  if(!(date = date_this(jsthis)))
727 
728  if(isnan(date->time)) {
729  if(r)
730  *r = jsval_string(jsstr_nan());
731  return S_OK;
732  }
733 
734  if(r) {
736 
737  week[0] = 0;
738  GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week, ARRAY_SIZE(week));
739 
740  month[0] = 0;
741  GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)], month, ARRAY_SIZE(month));
742 
743  year = year_from_time(date->time);
744  if(year<0) {
745  formatAD = FALSE;
746  year = -year+1;
747  }
748 
749  day = date_from_time(date->time);
750 
751  swprintf(buf, formatAD ? formatADW : formatBCW, week, day, month, year,
752  (int)hour_from_time(date->time), (int)min_from_time(date->time),
753  (int)sec_from_time(date->time));
754 
755  date_str = jsstr_alloc(buf);
756  if(!date_str)
757  return E_OUTOFMEMORY;
758 
759  *r = jsval_string(date_str);
760  }
761  return S_OK;
762 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
jsstr_t * jsstr_nan(void)
Definition: jsstr.c:283
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
#define MAKELCID(lgid, srtid)
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define TRUE
Definition: types.h:120
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
Definition: jsstr.h:39
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
static DOUBLE day(DOUBLE time)
Definition: date.c:117
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SORT_DEFAULT
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LANG_ENGLISH
Definition: nls.h:52
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
int isnan(double x)
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define S_OK
Definition: intsafe.h:59
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define ARRAY_SIZE(a)
Definition: main.h:24
__u16 date
Definition: mkdosfs.c:366
#define MAKELANGID(p, s)
Definition: nls.h:15
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
int month[12]
Definition: systime.c:13

Referenced by Date_toGMTString(), and Date_toUTCString().

◆ date_from_jsdisp()

static DateInstance* date_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 101 of file date.c.

102 {
103  return CONTAINING_RECORD(jsdisp, DateInstance, dispex);
104 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by Date_get_value(), date_this(), and DateConstr_value().

◆ date_from_time()

static DOUBLE date_from_time ( DOUBLE  time)
inlinestatic

Definition at line 252 of file date.c.

253 {
254  int dwy = day_within_year(time);
255  int ily = in_leap_year(time);
256  int mft = month_from_time(time);
257 
258  if(isnan(time))
259  return NAN;
260 
261  if(mft==0) return dwy+1;
262  if(mft==1) return dwy-30;
263  if(mft==2) return dwy-58-ily;
264  if(mft==3) return dwy-89-ily;
265  if(mft==4) return dwy-119-ily;
266  if(mft==5) return dwy-150-ily;
267  if(mft==6) return dwy-180-ily;
268  if(mft==7) return dwy-211-ily;
269  if(mft==8) return dwy-242-ily;
270  if(mft==9) return dwy-272-ily;
271  if(mft==10) return dwy-303-ily;
272  return dwy-333-ily;
273 }
__u16 time
Definition: mkdosfs.c:366
#define NAN
Definition: misc.c:46
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
int isnan(double x)
static int day_within_year(DOUBLE time)
Definition: date.c:223
static int in_leap_year(DOUBLE time)
Definition: date.c:215

Referenced by create_systemtime(), create_utc_string(), Date_getDate(), Date_getUTCDate(), Date_setFullYear(), Date_setMonth(), Date_setUTCFullYear(), Date_setUTCMonth(), Date_setYear(), date_to_string(), Date_toISOString(), and dateobj_to_date_string().

◆ Date_get_value()

static HRESULT Date_get_value ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 1931 of file date.c.

1932 {
1933  TRACE("\n");
1934 
1935  return dateobj_to_string(date_from_jsdisp(jsthis), r);
1936 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DateInstance * date_from_jsdisp(jsdisp_t *jsdisp)
Definition: date.c:101
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT dateobj_to_string(DateInstance *date, jsval_t *r)
Definition: date.c:570

◆ Date_getDate()

static HRESULT Date_getDate ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1066 of file date.c.

1067 {
1068  DateInstance *date;
1069 
1070  TRACE("\n");
1071 
1072  if(!(date = date_this(jsthis)))
1074 
1075  if(r)
1077  return S_OK;
1078 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getDay()

static HRESULT Date_getDay ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1097 of file date.c.

1099 {
1100  DateInstance *date;
1101 
1102  TRACE("\n");
1103 
1104  if(!(date = date_this(jsthis)))
1106 
1107  if(r)
1108  *r = jsval_number(week_day(local_time(date->time, date)));
1109  return S_OK;
1110 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getFullYear()

static HRESULT Date_getFullYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1000 of file date.c.

1002 {
1003  DateInstance *date;
1004 
1005  TRACE("\n");
1006 
1007  if(!(date = date_this(jsthis)))
1009 
1010  if(r) {
1011  DOUBLE time = local_time(date->time, date);
1012 
1014  }
1015  return S_OK;
1016 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
__u16 time
Definition: mkdosfs.c:366
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
double DOUBLE
Definition: typedefs.h:68
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getHours()

static HRESULT Date_getHours ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1129 of file date.c.

1131 {
1132  DateInstance *date;
1133 
1134  TRACE("\n");
1135 
1136  if(!(date = date_this(jsthis)))
1138 
1139  if(r)
1141  return S_OK;
1142 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getMilliseconds()

static HRESULT Date_getMilliseconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1224 of file date.c.

1226 {
1227  DateInstance *date;
1228 
1229  TRACE("\n");
1230 
1231  if(!(date = date_this(jsthis)))
1233 
1234  if(r)
1236  return S_OK;
1237 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getMinutes()

static HRESULT Date_getMinutes ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1161 of file date.c.

1163 {
1164  DateInstance *date;
1165 
1166  TRACE("\n");
1167 
1168  if(!(date = date_this(jsthis)))
1170 
1171  if(r)
1173  return S_OK;
1174 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getMonth()

static HRESULT Date_getMonth ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1035 of file date.c.

1036 {
1037  DateInstance *date;
1038 
1039  TRACE("\n");
1040 
1041  if(!(date = date_this(jsthis)))
1043 
1044  if(r)
1046  return S_OK;
1047 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getSeconds()

static HRESULT Date_getSeconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1193 of file date.c.

1194 {
1195  DateInstance *date;
1196 
1197  TRACE("\n");
1198 
1199  if(!(date = date_this(jsthis)))
1201 
1202  if(r)
1204  return S_OK;
1205 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getTime()

static HRESULT Date_getTime ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 984 of file date.c.

986 {
988 
989  TRACE("\n");
990 
991  if(!(date = date_this(jsthis)))
993 
994  if(r)
995  *r = jsval_number(date->time);
996  return S_OK;
997 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getTimezoneOffset()

static HRESULT Date_getTimezoneOffset ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1256 of file date.c.

1258 {
1259  DateInstance *date;
1260 
1261  TRACE("\n");
1262 
1263  if(!(date = date_this(jsthis)))
1265 
1266  if(r)
1267  *r = jsval_number(floor((date->time-local_time(date->time, date))/MS_PER_MINUTE));
1268  return S_OK;
1269 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define MS_PER_MINUTE
Definition: date.c:114
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCDate()

static HRESULT Date_getUTCDate ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1081 of file date.c.

1083 {
1084  DateInstance *date;
1085 
1086  TRACE("\n");
1087 
1088  if(!(date = date_this(jsthis)))
1090 
1091  if(r)
1092  *r = jsval_number(date_from_time(date->time));
1093  return S_OK;
1094 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCDay()

static HRESULT Date_getUTCDay ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1113 of file date.c.

1115 {
1116  DateInstance *date;
1117 
1118  TRACE("\n");
1119 
1120  if(!(date = date_this(jsthis)))
1122 
1123  if(r)
1124  *r = jsval_number(week_day(date->time));
1125  return S_OK;
1126 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCFullYear()

static HRESULT Date_getUTCFullYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1019 of file date.c.

1021 {
1022  DateInstance *date;
1023 
1024  TRACE("\n");
1025 
1026  if(!(date = date_this(jsthis)))
1028 
1029  if(r)
1030  *r = jsval_number(year_from_time(date->time));
1031  return S_OK;
1032 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCHours()

static HRESULT Date_getUTCHours ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1145 of file date.c.

1147 {
1148  DateInstance *date;
1149 
1150  TRACE("\n");
1151 
1152  if(!(date = date_this(jsthis)))
1154 
1155  if(r)
1156  *r = jsval_number(hour_from_time(date->time));
1157  return S_OK;
1158 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCMilliseconds()

static HRESULT Date_getUTCMilliseconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1240 of file date.c.

1242 {
1243  DateInstance *date;
1244 
1245  TRACE("\n");
1246 
1247  if(!(date = date_this(jsthis)))
1249 
1250  if(r)
1251  *r = jsval_number(ms_from_time(date->time));
1252  return S_OK;
1253 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCMinutes()

static HRESULT Date_getUTCMinutes ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1177 of file date.c.

1179 {
1180  DateInstance *date;
1181 
1182  TRACE("\n");
1183 
1184  if(!(date = date_this(jsthis)))
1186 
1187  if(r)
1188  *r = jsval_number(min_from_time(date->time));
1189  return S_OK;
1190 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCMonth()

static HRESULT Date_getUTCMonth ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1050 of file date.c.

1052 {
1053  DateInstance *date;
1054 
1055  TRACE("\n");
1056 
1057  if(!(date = date_this(jsthis)))
1059 
1060  if(r)
1061  *r = jsval_number(month_from_time(date->time));
1062  return S_OK;
1063 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getUTCSeconds()

static HRESULT Date_getUTCSeconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1208 of file date.c.

1210 {
1211  DateInstance *date;
1212 
1213  TRACE("\n");
1214 
1215  if(!(date = date_this(jsthis)))
1217 
1218  if(r)
1219  *r = jsval_number(sec_from_time(date->time));
1220  return S_OK;
1221 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_getYear()

static HRESULT Date_getYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1867 of file date.c.

1869 {
1870  DateInstance *date;
1871  DOUBLE t, year;
1872 
1873  TRACE("\n");
1874 
1875  if(!(date = date_this(jsthis)))
1877 
1878  t = local_time(date->time, date);
1879  if(isnan(t)) {
1880  if(r)
1881  *r = jsval_number(NAN);
1882  return S_OK;
1883  }
1884 
1885  year = year_from_time(t);
1886  if(r)
1887  *r = jsval_number((1900<=year && year<2000)?year-1900:year);
1888  return S_OK;
1889 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define NAN
Definition: misc.c:46
int isnan(double x)
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
double DOUBLE
Definition: typedefs.h:68
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ date_now()

static double date_now ( void  )
static

Definition at line 459 of file date.c.

460 {
461  FILETIME ftime;
462  LONGLONG time;
463 
465  time = ((LONGLONG)ftime.dwHighDateTime << 32) + ftime.dwLowDateTime;
466 
467  return time/10000 - TIME_EPOCH;
468 }
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
__u16 time
Definition: mkdosfs.c:366
int64_t LONGLONG
Definition: typedefs.h:66
__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb)
Definition: timeb.h:96
#define TIME_EPOCH
Definition: date.c:36

Referenced by DateConstr_now(), and DateConstr_value().

◆ date_parse()

static HRESULT date_parse ( jsstr_t input_str,
double ret 
)
inlinestatic

Definition at line 2035 of file date.c.

2035  {
2036  static const DWORD string_ids[] = { LOCALE_SMONTHNAME12, LOCALE_SMONTHNAME11,
2043  WCHAR *strings[ARRAY_SIZE(string_ids)];
2044  WCHAR *parse;
2045  int input_len, parse_len = 0, nest_level = 0, i, size;
2046  int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
2047  int ms = 0, offset = 0, hour_adjust = 0;
2048  BOOL set_year = FALSE, set_month = FALSE, set_day = FALSE, set_hour = FALSE;
2049  BOOL set_offset = FALSE, set_era = FALSE, ad = TRUE, set_am = FALSE, am = TRUE;
2050  BOOL set_hour_adjust = TRUE;
2052  const WCHAR *input;
2053  DateInstance di;
2054  DWORD lcid_en;
2055 
2056  input_len = jsstr_length(input_str);
2057  input = jsstr_flatten(input_str);
2058  if(!input)
2059  return E_OUTOFMEMORY;
2060 
2061  for(i=0; i<input_len; i++) {
2062  if(input[i] == '(') nest_level++;
2063  else if(input[i] == ')') {
2064  nest_level--;
2065  if(nest_level<0) {
2066  *ret = NAN;
2067  return S_OK;
2068  }
2069  }
2070  else if(!nest_level) parse_len++;
2071  }
2072 
2073  parse = heap_alloc((parse_len+1)*sizeof(WCHAR));
2074  if(!parse)
2075  return E_OUTOFMEMORY;
2076  nest_level = 0;
2077  parse_len = 0;
2078  for(i=0; i<input_len; i++) {
2079  if(input[i] == '(') nest_level++;
2080  else if(input[i] == ')') nest_level--;
2081  else if(!nest_level) parse[parse_len++] = towupper(input[i]);
2082  }
2083  parse[parse_len] = 0;
2084 
2085  GetTimeZoneInformation(&tzi);
2086  di.bias = tzi.Bias;
2087  di.standardDate = tzi.StandardDate;
2088  di.standardBias = tzi.StandardBias;
2089  di.daylightDate = tzi.DaylightDate;
2090  di.daylightBias = tzi.DaylightBias;
2091 
2092  /* FIXME: Cache strings */
2094  for(i=0; i<ARRAY_SIZE(string_ids); i++) {
2095  size = GetLocaleInfoW(lcid_en, string_ids[i], NULL, 0);
2096  strings[i] = heap_alloc((size+1)*sizeof(WCHAR));
2097  if(!strings[i]) {
2098  i--;
2099  while(i-- >= 0)
2100  heap_free(strings[i]);
2101  heap_free(parse);
2102  return E_OUTOFMEMORY;
2103  }
2104  GetLocaleInfoW(lcid_en, string_ids[i], strings[i], size);
2105  }
2106 
2107  for(i=0; i<parse_len;) {
2108  while(iswspace(parse[i])) i++;
2109  if(parse[i] == ',') {
2110  while(parse[i] == ',') i++;
2111  continue;
2112  }
2113 
2114  if(parse[i]>='0' && parse[i]<='9') {
2115  int tmp = wcstol(&parse[i], NULL, 10);
2116  while(parse[i]>='0' && parse[i]<='9') i++;
2117  while(iswspace(parse[i])) i++;
2118 
2119  if(parse[i] == ':') {
2120  /* Time */
2121  if(set_hour) break;
2122  set_hour = TRUE;
2123 
2124  hour = tmp;
2125 
2126  while(parse[i] == ':') i++;
2127  while(iswspace(parse[i])) i++;
2128  if(parse[i]>='0' && parse[i]<='9') {
2129  min = wcstol(&parse[i], NULL, 10);
2130  while(parse[i]>='0' && parse[i]<='9') i++;
2131  }
2132 
2133  while(iswspace(parse[i])) i++;
2134  while(parse[i] == ':') i++;
2135  while(iswspace(parse[i])) i++;
2136  if(parse[i]>='0' && parse[i]<='9') {
2137  sec = wcstol(&parse[i], NULL, 10);
2138  while(parse[i]>='0' && parse[i]<='9') i++;
2139  }
2140  }
2141  else if(parse[i]=='-' || parse[i]=='/') {
2142  /* Short or long date */
2143  if(set_day || set_month || set_year) break;
2144  set_day = TRUE;
2145  set_month = TRUE;
2146  set_year = TRUE;
2147 
2148  month = tmp-1;
2149 
2150  while(iswspace(parse[i])) i++;
2151  while(parse[i]=='-' || parse[i]=='/') i++;
2152  while(iswspace(parse[i])) i++;
2153  if(parse[i]<'0' || parse[i]>'9') break;
2154  day = wcstol(&parse[i], NULL, 10);
2155  while(parse[i]>='0' && parse[i]<='9') i++;
2156 
2157  while(parse[i]=='-' || parse[i]=='/') i++;
2158  while(iswspace(parse[i])) i++;
2159  if(parse[i]<'0' || parse[i]>'9') break;
2160  year = wcstol(&parse[i], NULL, 10);
2161  while(parse[i]>='0' && parse[i]<='9') i++;
2162 
2163  if(tmp >= 70){
2164  /* long date */
2165  month = day - 1;
2166  day = year;
2167  year = tmp;
2168  }
2169  }
2170  else if(tmp<0) break;
2171  else if(tmp<70) {
2172  /* Day */
2173  if(set_day) break;
2174  set_day = TRUE;
2175  day = tmp;
2176  }
2177  else {
2178  /* Year */
2179  if(set_year) break;
2180  set_year = TRUE;
2181  year = tmp;
2182  }
2183  }
2184  else if(parse[i]=='+' || parse[i]=='-') {
2185  /* Timezone offset */
2186  BOOL positive = TRUE;
2187 
2188  if(set_offset && set_hour_adjust) break;
2189  set_offset = TRUE;
2190  set_hour_adjust = FALSE;
2191 
2192  if(parse[i] == '-') positive = FALSE;
2193 
2194  i++;
2195  while(iswspace(parse[i])) i++;
2196  if(parse[i]<'0' || parse[i]>'9') break;
2197  offset = wcstol(&parse[i], NULL, 10);
2198  while(parse[i]>='0' && parse[i]<='9') i++;
2199 
2200  if(offset<24) offset *= 60;
2201  else offset = (offset/100)*60 + offset%100;
2202 
2203  if(positive) offset = -offset;
2204 
2205  }
2206  else {
2207  if(parse[i]<'A' || parse[i]>'Z') break;
2208  else if(parse[i]=='B' && (parse[i+1]=='C' ||
2209  (parse[i+1]=='.' && parse[i+2]=='C'))) {
2210  /* AD/BC */
2211  if(set_era) break;
2212  set_era = TRUE;
2213  ad = FALSE;
2214 
2215  i++;
2216  if(parse[i] == '.') i++;
2217  i++;
2218  if(parse[i] == '.') i++;
2219  }
2220  else if(parse[i]=='A' && (parse[i+1]=='D' ||
2221  (parse[i+1]=='.' && parse[i+2]=='D'))) {
2222  /* AD/BC */
2223  if(set_era) break;
2224  set_era = TRUE;
2225 
2226  i++;
2227  if(parse[i] == '.') i++;
2228  i++;
2229  if(parse[i] == '.') i++;
2230  }
2231  else if(parse[i+1]<'A' || parse[i+1]>'Z') {
2232  /* Timezone */
2233  if(set_offset) break;
2234  set_offset = TRUE;
2235 
2236  if(parse[i] <= 'I') hour_adjust = parse[i]-'A'+2;
2237  else if(parse[i] == 'J') break;
2238  else if(parse[i] <= 'M') hour_adjust = parse[i]-'K'+11;
2239  else if(parse[i] <= 'Y') hour_adjust = parse[i]-'N';
2240  else hour_adjust = 1;
2241 
2242  i++;
2243  if(parse[i] == '.') i++;
2244  }
2245  else if(parse[i]=='A' && parse[i+1]=='M') {
2246  /* AM/PM */
2247  if(set_am) break;
2248  set_am = TRUE;
2249  am = TRUE;
2250  i += 2;
2251  }
2252  else if(parse[i]=='P' && parse[i+1]=='M') {
2253  /* AM/PM */
2254  if(set_am) break;
2255  set_am = TRUE;
2256  am = FALSE;
2257  i += 2;
2258  }
2259  else if((parse[i]=='U' && parse[i+1]=='T' && parse[i+2]=='C')
2260  || (parse[i]=='G' && parse[i+1]=='M' && parse[i+2]=='T')) {
2261  /* Timezone */
2262  if(set_offset) break;
2263  set_offset = TRUE;
2264  set_hour_adjust = FALSE;
2265 
2266  i += 3;
2267  }
2268  else {
2269  /* Month or garbage */
2270  unsigned int j;
2271 
2272  for(size=i; parse[size]>='A' && parse[size]<='Z'; size++);
2273  size -= i;
2274 
2275  for(j=0; j<ARRAY_SIZE(string_ids); j++)
2276  if(!_wcsnicmp(&parse[i], strings[j], size)) break;
2277 
2278  if(j < 12) {
2279  if(set_month) break;
2280  set_month = TRUE;
2281  month = 11-j;
2282  }
2283  else if(j == ARRAY_SIZE(string_ids)) break;
2284 
2285  i += size;
2286  }
2287  }
2288  }
2289 
2290  if(i == parse_len && set_year && set_month && set_day && (!set_am || hour<13)) {
2291  if(set_am) {
2292  if(hour == 12) hour = 0;
2293  if(!am) hour += 12;
2294  }
2295 
2296  if(!ad) year = -year+1;
2297  else if(year<100) year += 1900;
2298 
2299  *ret = time_clip(make_date(make_day(year, month, day),
2300  make_time(hour+hour_adjust, min, sec, ms)) + offset*MS_PER_MINUTE);
2301 
2302  if(set_hour_adjust)
2303  *ret = utc(*ret, &di);
2304  }else {
2305  *ret = NAN;
2306  }
2307 
2308  for(i=0; i<ARRAY_SIZE(string_ids); i++)
2309  heap_free(strings[i]);
2310  heap_free(parse);
2311 
2312  return S_OK;
2313 }
static const WCHAR * jsstr_flatten(jsstr_t *str)
Definition: jsstr.h:139
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
LONG daylightBias
Definition: date.c:48
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
static DOUBLE day(DOUBLE time)
Definition: date.c:117
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
GLintptr offset
Definition: glext.h:5920
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LONG standardBias
Definition: date.c:46
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define MS_PER_MINUTE
Definition: date.c:114
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
SYSTEMTIME standardDate
Definition: date.c:45
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
SYSTEMTIME daylightDate
Definition: date.c:47
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
GLsizeiptr size
Definition: glext.h:5919
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SORT_DEFAULT
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NAN
Definition: misc.c:46
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LANG_ENGLISH
Definition: nls.h:52
#define iswspace(_c)
Definition: ctype.h:669
int ret
GLsizei const GLchar *const * strings
Definition: glext.h:7622
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
SYSTEMTIME StandardDate
Definition: winbase.h:1168
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
GLenum GLenum GLenum input
Definition: glext.h:9031
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
#define ARRAY_SIZE(a)
Definition: main.h:24
#define min(a, b)
Definition: monoChain.cc:55
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
LONG bias
Definition: date.c:44
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define MAKELANGID(p, s)
Definition: nls.h:15
#define towupper(c)
Definition: wctype.h:99
int month[12]
Definition: systime.c:13
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
SYSTEMTIME DaylightDate
Definition: winbase.h:1171
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: unary.h:15

Referenced by DateConstr_parse(), and DateConstr_value().

◆ Date_setDate()

static HRESULT Date_setDate ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1639 of file date.c.

1641 {
1642  DateInstance *date;
1643  double t, n;
1644  HRESULT hres;
1645 
1646  TRACE("\n");
1647 
1648  if(!(date = date_this(jsthis)))
1650 
1651  if(!argc)
1652  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1653 
1654  hres = to_number(ctx, argv[0], &n);
1655  if(FAILED(hres))
1656  return hres;
1657 
1658  t = local_time(date->time, date);
1660  date->time = time_clip(utc(t, date));
1661 
1662  if(r)
1663  *r = jsval_number(date->time);
1664  return S_OK;
1665 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setFullYear()

static HRESULT Date_setFullYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1775 of file date.c.

1777 {
1778  DateInstance *date;
1779  double t, year, month, ddate;
1780  HRESULT hres;
1781 
1782  TRACE("\n");
1783 
1784  if(!(date = date_this(jsthis)))
1786 
1787  if(!argc)
1788  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1789 
1790  t = local_time(date->time, date);
1791 
1792  hres = to_number(ctx, argv[0], &year);
1793  if(FAILED(hres))
1794  return hres;
1795 
1796  if(argc > 1) {
1797  hres = to_number(ctx, argv[1], &month);
1798  if(FAILED(hres))
1799  return hres;
1800  }else {
1801  month = month_from_time(t);
1802  }
1803 
1804  if(argc > 2) {
1805  hres = to_number(ctx, argv[2], &ddate);
1806  if(FAILED(hres))
1807  return hres;
1808  }else {
1809  ddate = date_from_time(t);
1810  }
1811 
1812  t = make_date(make_day(year, month, ddate), time_within_day(t));
1813  date->time = time_clip(utc(t, date));
1814 
1815  if(r)
1816  *r = jsval_number(date->time);
1817  return S_OK;
1818 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
int month[12]
Definition: systime.c:13
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setHours()

static HRESULT Date_setHours ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1531 of file date.c.

1533 {
1534  DateInstance *date;
1535  double t, hour, min, sec, ms;
1536  HRESULT hres;
1537 
1538  TRACE("\n");
1539 
1540  if(!(date = date_this(jsthis)))
1542 
1543  if(!argc)
1544  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1545 
1546  t = local_time(date->time, date);
1547 
1548  hres = to_number(ctx, argv[0], &hour);
1549  if(FAILED(hres))
1550  return hres;
1551 
1552  if(argc > 1) {
1553  hres = to_number(ctx, argv[1], &min);
1554  if(FAILED(hres))
1555  return hres;
1556  }else {
1557  min = min_from_time(t);
1558  }
1559 
1560  if(argc > 2) {
1561  hres = to_number(ctx, argv[2], &sec);
1562  if(FAILED(hres))
1563  return hres;
1564  }else {
1565  sec = sec_from_time(t);
1566  }
1567 
1568  if(argc > 3) {
1569  hres = to_number(ctx, argv[3], &ms);
1570  if(FAILED(hres))
1571  return hres;
1572  }else {
1573  ms = ms_from_time(t);
1574  }
1575 
1576  t = make_date(day(t), make_time(hour, min, sec, ms));
1577  date->time = time_clip(utc(t, date));
1578 
1579  if(r)
1580  *r = jsval_number(date->time);
1581  return S_OK;
1582 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
#define min(a, b)
Definition: monoChain.cc:55
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setMilliseconds()

static HRESULT Date_setMilliseconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1299 of file date.c.

1301 {
1302  DateInstance *date;
1303  double n, t;
1304  HRESULT hres;
1305 
1306  TRACE("\n");
1307 
1308  if(!(date = date_this(jsthis)))
1310 
1311  if(!argc)
1312  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1313 
1314  hres = to_number(ctx, argv[0], &n);
1315  if(FAILED(hres))
1316  return hres;
1317 
1318  t = local_time(date->time, date);
1320  sec_from_time(t), n));
1321  date->time = time_clip(utc(t, date));
1322 
1323  if(r)
1324  *r = jsval_number(date->time);
1325  return S_OK;
1326 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setMinutes()

static HRESULT Date_setMinutes ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1437 of file date.c.

1439 {
1440  DateInstance *date;
1441  double t, min, sec, ms;
1442  HRESULT hres;
1443 
1444  TRACE("\n");
1445 
1446  if(!(date = date_this(jsthis)))
1448 
1449  if(!argc)
1450  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1451 
1452  t = local_time(date->time, date);
1453 
1454  hres = to_number(ctx, argv[0], &min);
1455  if(FAILED(hres))
1456  return hres;
1457 
1458  if(argc > 1) {
1459  hres = to_number(ctx, argv[1], &sec);
1460  if(FAILED(hres))
1461  return hres;
1462  }else {
1463  sec = sec_from_time(t);
1464  }
1465 
1466  if(argc > 2) {
1467  hres = to_number(ctx, argv[2], &ms);
1468  if(FAILED(hres))
1469  return hres;
1470  }else {
1471  ms = ms_from_time(t);
1472  }
1473 
1475  min, sec, ms));
1476  date->time = time_clip(utc(t, date));
1477 
1478  if(r)
1479  *r = jsval_number(date->time);
1480  return S_OK;
1481 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
#define min(a, b)
Definition: monoChain.cc:55
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setMonth()

static HRESULT Date_setMonth ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1697 of file date.c.

1699 {
1700  DateInstance *date;
1701  DOUBLE t, month, ddate;
1702  HRESULT hres;
1703 
1704  TRACE("\n");
1705 
1706  if(!(date = date_this(jsthis)))
1708 
1709  if(!argc)
1710  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1711 
1712  t = local_time(date->time, date);
1713 
1714  hres = to_number(ctx, argv[0], &month);
1715  if(FAILED(hres))
1716  return hres;
1717 
1718  if(argc > 1) {
1719  hres = to_number(ctx, argv[1], &ddate);
1720  if(FAILED(hres))
1721  return hres;
1722  }else {
1723  ddate = date_from_time(t);
1724  }
1725 
1726  t = make_date(make_day(year_from_time(t), month, ddate),
1727  time_within_day(t));
1728  date->time = time_clip(utc(t, date));
1729 
1730  if(r)
1731  *r = jsval_number(date->time);
1732  return S_OK;
1733 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
double DOUBLE
Definition: typedefs.h:68
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
int month[12]
Definition: systime.c:13
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setSeconds()

static HRESULT Date_setSeconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1359 of file date.c.

1361 {
1362  DateInstance *date;
1363  double t, sec, ms;
1364  HRESULT hres;
1365 
1366  TRACE("\n");
1367 
1368  if(!(date = date_this(jsthis)))
1370 
1371  if(!argc)
1372  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1373 
1374  t = local_time(date->time, date);
1375 
1376  hres = to_number(ctx, argv[0], &sec);
1377  if(FAILED(hres))
1378  return hres;
1379 
1380  if(argc > 1) {
1381  hres = to_number(ctx, argv[1], &ms);
1382  if(FAILED(hres))
1383  return hres;
1384  }else {
1385  ms = ms_from_time(t);
1386  }
1387 
1389  min_from_time(t), sec, ms));
1390  date->time = time_clip(utc(t, date));
1391 
1392  if(r)
1393  *r = jsval_number(date->time);
1394  return S_OK;
1395 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setTime()

static HRESULT Date_setTime ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1272 of file date.c.

1274 {
1275  double n;
1276  HRESULT hres;
1277  DateInstance *date;
1278 
1279  TRACE("\n");
1280 
1281  if(!(date = date_this(jsthis)))
1283 
1284  if(!argc)
1285  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1286 
1287  hres = to_number(ctx, argv[0], &n);
1288  if(FAILED(hres))
1289  return hres;
1290 
1291  date->time = time_clip(n);
1292 
1293  if(r)
1294  *r = jsval_number(date->time);
1295  return S_OK;
1296 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCDate()

static HRESULT Date_setUTCDate ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1668 of file date.c.

1670 {
1671  DateInstance *date;
1672  double t, n;
1673  HRESULT hres;
1674 
1675  TRACE("\n");
1676 
1677  if(!(date = date_this(jsthis)))
1679 
1680  if(!argc)
1681  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1682 
1683  hres = to_number(ctx, argv[0], &n);
1684  if(FAILED(hres))
1685  return hres;
1686 
1687  t = date->time;
1689  date->time = time_clip(t);
1690 
1691  if(r)
1692  *r = jsval_number(date->time);
1693  return S_OK;
1694 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCFullYear()

static HRESULT Date_setUTCFullYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1821 of file date.c.

1823 {
1824  DateInstance *date;
1825  double t, year, month, ddate;
1826  HRESULT hres;
1827 
1828  TRACE("\n");
1829 
1830  if(!(date = date_this(jsthis)))
1832 
1833  if(!argc)
1834  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1835 
1836  t = date->time;
1837 
1838  hres = to_number(ctx, argv[0], &year);
1839  if(FAILED(hres))
1840  return hres;
1841 
1842  if(argc > 1) {
1843  hres = to_number(ctx, argv[1], &month);
1844  if(FAILED(hres))
1845  return hres;
1846  }else {
1847  month = month_from_time(t);
1848  }
1849 
1850  if(argc > 2) {
1851  hres = to_number(ctx, argv[2], &ddate);
1852  if(FAILED(hres))
1853  return hres;
1854  }else {
1855  ddate = date_from_time(t);
1856  }
1857 
1858  t = make_date(make_day(year, month, ddate), time_within_day(t));
1859  date->time = time_clip(t);
1860 
1861  if(r)
1862  *r = jsval_number(date->time);
1863  return S_OK;
1864 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
int month[12]
Definition: systime.c:13
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCHours()

static HRESULT Date_setUTCHours ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1585 of file date.c.

1587 {
1588  DateInstance *date;
1589  double t, hour, min, sec, ms;
1590  HRESULT hres;
1591 
1592  TRACE("\n");
1593 
1594  if(!(date = date_this(jsthis)))
1596 
1597  if(!argc)
1598  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1599 
1600  t = date->time;
1601 
1602  hres = to_number(ctx, argv[0], &hour);
1603  if(FAILED(hres))
1604  return hres;
1605 
1606  if(argc > 1) {
1607  hres = to_number(ctx, argv[1], &min);
1608  if(FAILED(hres))
1609  return hres;
1610  }else {
1611  min = min_from_time(t);
1612  }
1613 
1614  if(argc > 2) {
1615  hres = to_number(ctx, argv[2], &sec);
1616  if(FAILED(hres))
1617  return hres;
1618  }else {
1619  sec = sec_from_time(t);
1620  }
1621 
1622  if(argc > 3) {
1623  hres = to_number(ctx, argv[3], &ms);
1624  if(FAILED(hres))
1625  return hres;
1626  }else {
1627  ms = ms_from_time(t);
1628  }
1629 
1630  t = make_date(day(t), make_time(hour, min, sec, ms));
1631  date->time = time_clip(t);
1632 
1633  if(r)
1634  *r = jsval_number(date->time);
1635  return S_OK;
1636 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
#define min(a, b)
Definition: monoChain.cc:55
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCMilliseconds()

static HRESULT Date_setUTCMilliseconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1329 of file date.c.

1331 {
1332  DateInstance *date;
1333  double n, t;
1334  HRESULT hres;
1335 
1336  TRACE("\n");
1337 
1338  if(!(date = date_this(jsthis)))
1340 
1341  if(!argc)
1342  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1343 
1344  hres = to_number(ctx, argv[0], &n);
1345  if(FAILED(hres))
1346  return hres;
1347 
1348  t = date->time;
1350  sec_from_time(t), n));
1351  date->time = time_clip(t);
1352 
1353  if(r)
1354  *r = jsval_number(date->time);
1355  return S_OK;
1356 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCMinutes()

static HRESULT Date_setUTCMinutes ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1484 of file date.c.

1486 {
1487  DateInstance *date;
1488  double t, min, sec, ms;
1489  HRESULT hres;
1490 
1491  TRACE("\n");
1492 
1493  if(!(date = date_this(jsthis)))
1495 
1496  if(!argc)
1497  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1498 
1499  t = date->time;
1500 
1501  hres = to_number(ctx, argv[0], &min);
1502  if(FAILED(hres))
1503  return hres;
1504 
1505  if(argc > 1) {
1506  hres = to_number(ctx, argv[1], &sec);
1507  if(FAILED(hres))
1508  return hres;
1509  }else {
1510  sec = sec_from_time(t);
1511  }
1512 
1513  if(argc > 2) {
1514  hres = to_number(ctx, argv[2], &ms);
1515  if(FAILED(hres))
1516  return hres;
1517  }else {
1518  ms = ms_from_time(t);
1519  }
1520 
1522  min, sec, ms));
1523  date->time = time_clip(t);
1524 
1525  if(r)
1526  *r = jsval_number(date->time);
1527  return S_OK;
1528 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
#define min(a, b)
Definition: monoChain.cc:55
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCMonth()

static HRESULT Date_setUTCMonth ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1736 of file date.c.

1738 {
1739  DateInstance *date;
1740  double t, month, ddate;
1741  HRESULT hres;
1742 
1743  TRACE("\n");
1744 
1745  if(!(date = date_this(jsthis)))
1747 
1748  if(!argc)
1749  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1750 
1751  t = date->time;
1752 
1753  hres = to_number(ctx, argv[0], &month);
1754  if(FAILED(hres))
1755  return hres;
1756 
1757  if(argc > 1) {
1758  hres = to_number(ctx, argv[1], &ddate);
1759  if(FAILED(hres))
1760  return hres;
1761  }else {
1762  ddate = date_from_time(t);
1763  }
1764 
1765  t = make_date(make_day(year_from_time(t), month, ddate),
1766  time_within_day(t));
1767  date->time = time_clip(t);
1768 
1769  if(r)
1770  *r = jsval_number(date->time);
1771  return S_OK;
1772 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
int month[12]
Definition: systime.c:13
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setUTCSeconds()

static HRESULT Date_setUTCSeconds ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1398 of file date.c.

1400 {
1401  DateInstance *date;
1402  double t, sec, ms;
1403  HRESULT hres;
1404 
1405  TRACE("\n");
1406 
1407  if(!(date = date_this(jsthis)))
1409 
1410  if(!argc)
1411  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1412 
1413  t = date->time;
1414 
1415  hres = to_number(ctx, argv[0], &sec);
1416  if(FAILED(hres))
1417  return hres;
1418 
1419  if(argc > 1) {
1420  hres = to_number(ctx, argv[1], &ms);
1421  if(FAILED(hres))
1422  return hres;
1423  }else {
1424  ms = ms_from_time(t);
1425  }
1426 
1428  min_from_time(t), sec, ms));
1429  date->time = time_clip(t);
1430 
1431  if(r)
1432  *r = jsval_number(date->time);
1433  return S_OK;
1434 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLdouble GLdouble t
Definition: gl.h:2047
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:406
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:420
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Date_setYear()

static HRESULT Date_setYear ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1892 of file date.c.

1894 {
1895  DateInstance *date;
1896  DOUBLE t, year;
1897  HRESULT hres;
1898 
1899  TRACE("\n");
1900 
1901  if(!(date = date_this(jsthis)))
1903 
1904  if(!argc)
1905  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1906 
1907  t = local_time(date->time, date);
1908 
1909  hres = to_number(ctx, argv[0], &year);
1910  if(FAILED(hres))
1911  return hres;
1912 
1913  if(isnan(year)) {
1914  date->time = year;
1915  if(r)
1916  *r = jsval_number(NAN);
1917  return S_OK;
1918  }
1919 
1920  year = year >= 0.0 ? floor(year) : -floor(-year);
1921  if(-1.0 < year && year < 100.0)
1922  year += 1900.0;
1923 
1925 
1926  if(r)
1927  *r = jsval_number(date->time);
1928  return S_OK;
1929 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
#define JS_E_MISSING_ARG
Definition: jscript.h:535
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:351
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:426
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:123
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:450
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:444
int isnan(double x)
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
__u16 date
Definition: mkdosfs.c:366
double DOUBLE
Definition: typedefs.h:68
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ date_this()

◆ date_to_string()

static HRESULT date_to_string ( DOUBLE  time,
BOOL  show_offset,
int  offset,
jsval_t r 
)
inlinestatic

Definition at line 486 of file date.c.

487 {
488  static const WCHAR formatW[] = { '%','s',' ','%','s',' ','%','d',' ',
489  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ',
490  'U','T','C','%','c','%','0','2','d','%','0','2','d',' ','%','d','%','s',0 };
491  static const WCHAR formatUTCW[] = { '%','s',' ','%','s',' ','%','d',' ',
492  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ',
493  'U','T','C',' ','%','d','%','s',0 };
494  static const WCHAR formatNoOffsetW[] = { '%','s',' ','%','s',' ',
495  '%','d',' ','%','0','2','d',':','%','0','2','d',':',
496  '%','0','2','d',' ','%','d','%','s',0 };
497  static const WCHAR ADW[] = { 0 };
498  static const WCHAR BCW[] = { ' ','B','.','C','.',0 };
499 
500  static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1,
503  static const DWORD month_ids[] = { LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2,
509 
510  BOOL formatAD = TRUE;
511  WCHAR week[64], month[64];
512  WCHAR buf[192];
513  jsstr_t *date_jsstr;
514  int year, day;
515  DWORD lcid_en;
516  WCHAR sign = '-';
517 
518  if(isnan(time)) {
519  if(r)
520  *r = jsval_string(jsstr_nan());
521  return S_OK;
522  }
523 
524  if(r) {
526 
527  week[0] = 0;
528  GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, ARRAY_SIZE(week));
529 
530  month[0] = 0;
531  GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, ARRAY_SIZE(month));
532 
533  year = year_from_time(time);
534  if(year<0) {
535  formatAD = FALSE;
536  year = -year+1;
537  }
538 
540 
541  if(offset < 0) {
542  sign = '+';
543  offset = -offset;
544  }
545 
546  if(!show_offset)
547  swprintf(buf, formatNoOffsetW, week, month, day,
548  (int)hour_from_time(time), (int)min_from_time(time),
549  (int)sec_from_time(time), year, formatAD?ADW:BCW);
550  else if(offset)
551  swprintf(buf, formatW, week, month, day,
552  (int)hour_from_time(time), (int)min_from_time(time),
553  (int)sec_from_time(time), sign, offset/60, offset%60,
554  year, formatAD?ADW:BCW);
555  else
556  swprintf(buf, formatUTCW, week, month, day,
557  (int)hour_from_time(time), (int)min_from_time(time),
558  (int)sec_from_time(time), year, formatAD?ADW:BCW);
559 
560  date_jsstr = jsstr_alloc(buf);
561  if(!date_jsstr)
562  return E_OUTOFMEMORY;
563 
564  *r = jsval_string(date_jsstr);
565  }
566  return S_OK;
567 }
static size_t double int int int * sign
Definition: printf.c:69
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
jsstr_t * jsstr_nan(void)
Definition: jsstr.c:283
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
#define MAKELCID(lgid, srtid)
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define TRUE
Definition: types.h:120
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
static DOUBLE week_day(DOUBLE time)
Definition: date.c:276
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
Definition: jsstr.h:39
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:197
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
static DOUBLE day(DOUBLE time)
Definition: date.c:117
GLintptr offset
Definition: glext.h:5920
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
__u16 time
Definition: mkdosfs.c:366
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:364
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:252
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SORT_DEFAULT
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LANG_ENGLISH
Definition: nls.h:52
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:229
int isnan(double x)
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define S_OK
Definition: intsafe.h:59
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MAKELANGID(p, s)
Definition: nls.h:15
int month[12]
Definition: systime.c:13

Referenced by DateConstr_value(), and dateobj_to_string().

◆ Date_toDateString()

static HRESULT Date_toDateString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 839 of file date.c.

841 {
843 
844  if(!(date = date_this(jsthis)))
846 
847  return dateobj_to_date_string(date, r);
848 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
Definition: date.c:780
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440

◆ Date_toGMTString()

static HRESULT Date_toGMTString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 772 of file date.c.

774 {
775  TRACE("\n");
776  return create_utc_string(ctx, jsthis, r);
777 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
Definition: date.c:700

◆ Date_toISOString()

static HRESULT Date_toISOString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 638 of file date.c.

640 {
642  WCHAR buf[64], *p = buf;
643  double year;
644 
645  static const WCHAR short_year_formatW[] = {'%','0','4','d',0};
646  static const WCHAR long_year_formatW[] = {'%','0','6','d',0};
647  static const WCHAR formatW[] = {'-','%','0','2','d','-','%','0','2','d',
648  'T','%','0','2','d',':','%','0','2','d',':','%','0','2','d','.','%','0','3','d','Z',0};
649 
650  TRACE("\n");
651 
652  if(!(date = date_this(jsthis)))
654 
655  year = year_from_time(date->time);
656  if(isnan(year) || year > 999999 || year < -999999) {
657  FIXME("year %lf should throw an exception\n", year);
658  return E_FAIL;
659  }
660 
661  if(year < 0) {
662  *p++ = '-';
663  p += swprintf(p, long_year_formatW, -(int)year);
664  }else if(year > 9999) {
665  *p++ = '+';
666  p += swprintf(p, long_year_formatW, (int)year);
667  }else {
668  p += swprintf(p, short_year_formatW, (int)year);
669  }
670 
671  swprintf(p, formatW,
672  (int)month_from_time(date->time) + 1, (int)date_from_time(date->time),
673  (int)hour_from_time(date->time), (int)min_from_time(date->time),
674  (int)sec_from_time(date->time), (int)ms_from_time(date->time));
675 
676  if(r) {
677  jsstr_t *ret;
678  if(!(ret = jsstr_alloc(buf)))
679  return E_OUTOFMEMORY;
680  *r = jsval_string(ret);
681  }
682  return S_OK;
683 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:378
#define JS_E_DATE_EXPECTED
Definition: jscript.h:553
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:392
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:106
Definition: jsstr.h:39