ReactOS  0.4.13-dev-687-g023794c
date.c File Reference
#include "config.h"
#include "wine/port.h"
#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 110 of file date.c.

◆ MS_PER_HOUR

#define MS_PER_HOUR   3600000

Definition at line 111 of file date.c.

◆ MS_PER_MINUTE

#define MS_PER_MINUTE   60000

Definition at line 112 of file date.c.

◆ TIME_EPOCH

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

Definition at line 34 of file date.c.

Function Documentation

◆ convert_time()

static DOUBLE convert_time ( int  year,
SYSTEMTIME  st 
)
inlinestatic

Definition at line 287 of file date.c.

288 {
289  DOUBLE time;
290  int set_week_day;
291 
292  if(st.wMonth == 0)
293  return NAN;
294 
295  if(st.wYear != 0)
296  year = st.wYear;
297 
298  time = time_from_year(year);
300 
301  if(st.wYear == 0) {
302  set_week_day = st.wDayOfWeek-week_day(time);
303  if(set_week_day < 0)
304  set_week_day += 7;
305  time += set_week_day * MS_PER_DAY;
306 
307  time += (DOUBLE)(st.wDay-1) * 7 * MS_PER_DAY;
308  if(month_from_time(time) != st.wMonth-1)
309  time -= 7 * MS_PER_DAY;
310  }
311  else
312  time += st.wDay * MS_PER_DAY;
313 
314  time += st.wHour * MS_PER_HOUR;
315  time += st.wMinute * MS_PER_MINUTE;
316 
317  return time;
318 }
#define DOUBLE(x)
Definition: atom.c:30
static DOUBLE week_day(DOUBLE time)
Definition: date.c:274
WORD wMonth
Definition: winbase.h:871
WORD wDayOfWeek
Definition: winbase.h:872
#define MS_PER_HOUR
Definition: date.c:111
__u16 time
Definition: mkdosfs.c:366
#define MS_PER_DAY
Definition: date.c:110
WORD wYear
Definition: winbase.h:870
WORD wMinute
Definition: winbase.h:875
#define MS_PER_MINUTE
Definition: date.c:112
static int day_from_month(int month, int in_leap_year)
Definition: date.c:157
#define NAN
Definition: misc.c:46
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:227
WORD wDay
Definition: winbase.h:873
WORD wHour
Definition: winbase.h:874
static DOUBLE time_from_year(DOUBLE year)
Definition: date.c:189
double DOUBLE
Definition: typedefs.h:68
static int in_leap_year(DOUBLE time)
Definition: date.c:213

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 2000 of file date.c.

2001 {
2002  DateInstance *date;
2003  HRESULT hres;
2005 
2006  GetTimeZoneInformation(&tzi);
2007 
2008  date = heap_alloc_zero(sizeof(DateInstance));
2009  if(!date)
2010  return E_OUTOFMEMORY;
2011 
2012  if(object_prototype)
2013  hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
2014  else
2015  hres = init_dispex_from_constr(&date->dispex, ctx, &DateInst_info, ctx->date_constr);
2016  if(FAILED(hres)) {
2017  heap_free(date);
2018  return hres;
2019  }
2020 
2021  date->time = time;
2022  date->bias = tzi.Bias;
2023  date->standardDate = tzi.StandardDate;
2024  date->standardBias = tzi.StandardBias;
2025  date->daylightDate = tzi.DaylightDate;
2026  date->daylightBias = tzi.DaylightBias;
2027 
2028  *ret = &date->dispex;
2029  return S_OK;
2030 }
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:1992
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const builtin_info_t Date_info
Definition: date.c:1983
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
SYSTEMTIME StandardDate
Definition: winbase.h:1161
#define S_OK
Definition: intsafe.h:59
__u16 date
Definition: mkdosfs.c:366
jsdisp_t * date_constr
Definition: jscript.h:440
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1051
SYSTEMTIME DaylightDate
Definition: winbase.h:1164
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 2531 of file date.c.

2532 {
2533  jsdisp_t *date;
2534  HRESULT hres;
2535 
2536  static const WCHAR DateW[] = {'D','a','t','e',0};
2537 
2538  hres = create_date(ctx, object_prototype, 0.0, &date);
2539  if(FAILED(hres))
2540  return hres;
2541 
2543  PROPF_CONSTR|7, date, ret);
2544 
2546  return hres;
2547 }
static const WCHAR DateW[]
Definition: global.c:36
static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE time, jsdisp_t **ret)
Definition: date.c:2000
#define PROPF_CONSTR
Definition: jscript.h:95
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:679
static const builtin_info_t DateConstr_info
Definition: date.c:2522
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:2433
int ret
__u16 date
Definition: mkdosfs.c:366
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264

Referenced by init_constructors().

◆ create_systemtime()

static SYSTEMTIME create_systemtime ( DOUBLE  time)
static

Definition at line 468 of file date.c.

469 {
470  SYSTEMTIME st;
471 
472  st.wYear = year_from_time(time);
473  st.wMonth = month_from_time(time) + 1;
474  st.wDayOfWeek = week_day(time);
475  st.wDay = date_from_time(time);
476  st.wHour = hour_from_time(time);
477  st.wMinute = min_from_time(time);
478  st.wSecond = sec_from_time(time);
480 
481  return st;
482 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static DOUBLE week_day(DOUBLE time)
Definition: date.c:274
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
WORD wMonth
Definition: winbase.h:871
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
WORD wDayOfWeek
Definition: winbase.h:872
__u16 time
Definition: mkdosfs.c:366
WORD wYear
Definition: winbase.h:870
WORD wMinute
Definition: winbase.h:875
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
WORD wSecond
Definition: winbase.h:876
WORD wMilliseconds
Definition: winbase.h:877
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:227
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:404
WORD wDay
Definition: winbase.h:873
WORD wHour
Definition: winbase.h:874

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 697 of file date.c.

698 {
699  static const WCHAR formatADW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ',
700  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 };
701  static const WCHAR formatBCW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ','B','.','C','.',' ',
702  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 };
703 
704  static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1,
707  static const DWORD month_ids[] = { LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2,
713 
714  BOOL formatAD = TRUE;
715  WCHAR week[64], month[64];
716  WCHAR buf[192];
718  jsstr_t *date_str;
719  int year, day;
720  DWORD lcid_en;
721 
722  if(!(date = date_this(jsthis)))
724 
725  if(isnan(date->time)) {
726  if(r)
727  *r = jsval_string(jsstr_nan());
728  return S_OK;
729  }
730 
731  if(r) {
733 
734  week[0] = 0;
735  GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week, ARRAY_SIZE(week));
736 
737  month[0] = 0;
738  GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)], month, ARRAY_SIZE(month));
739 
740  year = year_from_time(date->time);
741  if(year<0) {
742  formatAD = FALSE;
743  year = -year+1;
744  }
745 
746  day = date_from_time(date->time);
747 
748  sprintfW(buf, formatAD ? formatADW : formatBCW, week, day, month, year,
749  (int)hour_from_time(date->time), (int)min_from_time(date->time),
750  (int)sec_from_time(date->time));
751 
752  date_str = jsstr_alloc(buf);
753  if(!date_str)
754  return E_OUTOFMEMORY;
755 
756  *r = jsval_string(date_str);
757  }
758  return S_OK;
759 }
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:376
#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:554
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
static DOUBLE week_day(DOUBLE time)
Definition: date.c:274
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
Definition: jsstr.h:39
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
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:115
#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:362
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
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
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:227
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 sprintfW
Definition: unicode.h:58
#define MAKELANGID(p, s)
Definition: nls.h:15
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
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 99 of file date.c.

100 {
101  return CONTAINING_RECORD(jsdisp, DateInstance, dispex);
102 }
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 250 of file date.c.

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

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 1928 of file date.c.

1929 {
1930  TRACE("\n");
1931 
1932  return dateobj_to_string(date_from_jsdisp(jsthis), r);
1933 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DateInstance * date_from_jsdisp(jsdisp_t *jsdisp)
Definition: date.c:99
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT dateobj_to_string(DateInstance *date, jsval_t *r)
Definition: date.c:568

◆ 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 1063 of file date.c.

1064 {
1065  DateInstance *date;
1066 
1067  TRACE("\n");
1068 
1069  if(!(date = date_this(jsthis)))
1071 
1072  if(r)
1074  return S_OK;
1075 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:438
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 1094 of file date.c.

1096 {
1097  DateInstance *date;
1098 
1099  TRACE("\n");
1100 
1101  if(!(date = date_this(jsthis)))
1103 
1104  if(r)
1105  *r = jsval_number(week_day(local_time(date->time, date)));
1106  return S_OK;
1107 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE week_day(DOUBLE time)
Definition: date.c:274
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
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:438
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 997 of file date.c.

999 {
1000  DateInstance *date;
1001 
1002  TRACE("\n");
1003 
1004  if(!(date = date_this(jsthis)))
1006 
1007  if(r) {
1008  DOUBLE time = local_time(date->time, date);
1009 
1011  }
1012  return S_OK;
1013 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
__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:438
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 1126 of file date.c.

1128 {
1129  DateInstance *date;
1130 
1131  TRACE("\n");
1132 
1133  if(!(date = date_this(jsthis)))
1135 
1136  if(r)
1138  return S_OK;
1139 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:438
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 1221 of file date.c.

1223 {
1224  DateInstance *date;
1225 
1226  TRACE("\n");
1227 
1228  if(!(date = date_this(jsthis)))
1230 
1231  if(r)
1233  return S_OK;
1234 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE ms_from_time(DOUBLE time)
Definition: date.c:404
#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:438
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 1158 of file date.c.

1160 {
1161  DateInstance *date;
1162 
1163  TRACE("\n");
1164 
1165  if(!(date = date_this(jsthis)))
1167 
1168  if(r)
1170  return S_OK;
1171 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
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:438
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 1032 of file date.c.

1033 {
1034  DateInstance *date;
1035 
1036  TRACE("\n");
1037 
1038  if(!(date = date_this(jsthis)))
1040 
1041  if(r)
1043  return S_OK;
1044 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static DOUBLE month_from_time(DOUBLE time)
Definition: date.c:227
#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:438
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 1190 of file date.c.

1191 {
1192  DateInstance *date;
1193 
1194  TRACE("\n");
1195 
1196  if(!(date = date_this(jsthis)))
1198 
1199  if(r)
1201  return S_OK;
1202 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
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:438
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 981 of file date.c.

983 {
985 
986  TRACE("\n");
987 
988  if(!(date = date_this(jsthis)))
990 
991  if(r)
992  *r = jsval_number(date->time);
993  return S_OK;
994 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:438
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 1253 of file date.c.

1255 {
1256  DateInstance *date;
1257 
1258  TRACE("\n");
1259 
1260  if(!(date = date_this(jsthis)))
1262 
1263  if(r)
1264  *r = jsval_number(floor((date->time-local_time(date->time, date))/MS_PER_MINUTE));
1265  return S_OK;
1266 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
smooth NULL
Definition: ftsmooth.c:416
#define MS_PER_MINUTE
Definition: date.c:112
#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:438
_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 1078 of file date.c.

1080 {
1081  DateInstance *date;
1082 
1083  TRACE("\n");
1084 
1085  if(!(date = date_this(jsthis)))
1087 
1088  if(r)
1089  *r = jsval_number(date_from_time(date->time));
1090  return S_OK;
1091 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:438
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 1110 of file date.c.

1112 {
1113  DateInstance *date;
1114 
1115  TRACE("\n");
1116 
1117  if(!(date = date_this(jsthis)))
1119 
1120  if(r)
1121  *r = jsval_number(week_day(date->time));
1122  return S_OK;
1123 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE week_day(DOUBLE time)
Definition: date.c:274
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:438
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 1016 of file date.c.

1018 {
1019  DateInstance *date;
1020 
1021  TRACE("\n");
1022 
1023  if(!(date = date_this(jsthis)))
1025 
1026  if(r)
1027  *r = jsval_number(year_from_time(date->time));
1028  return S_OK;
1029 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
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:438
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 1142 of file date.c.

1144 {
1145  DateInstance *date;
1146 
1147  TRACE("\n");
1148 
1149  if(!(date = date_this(jsthis)))
1151 
1152  if(r)
1153  *r = jsval_number(hour_from_time(date->time));
1154  return S_OK;
1155 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:438
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 1237 of file date.c.

1239 {
1240  DateInstance *date;
1241 
1242  TRACE("\n");
1243 
1244  if(!(date = date_this(jsthis)))
1246 
1247  if(r)
1248  *r = jsval_number(ms_from_time(date->time));
1249  return S_OK;
1250 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:404
#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:438
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 1174 of file date.c.

1176 {
1177  DateInstance *date;
1178 
1179  TRACE("\n");
1180 
1181  if(!(date = date_this(jsthis)))
1183 
1184  if(r)
1185  *r = jsval_number(min_from_time(date->time));
1186  return S_OK;
1187 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:438
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 1047 of file date.c.

1049 {
1050  DateInstance *date;
1051 
1052  TRACE("\n");
1053 
1054  if(!(date = date_this(jsthis)))
1056 
1057  if(r)
1058  *r = jsval_number(month_from_time(date->time));
1059  return S_OK;
1060 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:227
#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:438
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 1205 of file date.c.

1207 {
1208  DateInstance *date;
1209 
1210  TRACE("\n");
1211 
1212  if(!(date = date_this(jsthis)))
1214 
1215  if(r)
1216  *r = jsval_number(sec_from_time(date->time));
1217  return S_OK;
1218 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:438
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 1864 of file date.c.

1866 {
1867  DateInstance *date;
1868  DOUBLE t, year;
1869 
1870  TRACE("\n");
1871 
1872  if(!(date = date_this(jsthis)))
1874 
1875  t = local_time(date->time, date);
1876  if(isnan(t)) {
1877  if(r)
1878  *r = jsval_number(NAN);
1879  return S_OK;
1880  }
1881 
1882  year = year_from_time(t);
1883  if(r)
1884  *r = jsval_number((1900<=year && year<2000)?year-1900:year);
1885  return S_OK;
1886 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
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:349
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:438
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ date_now()

static double date_now ( void  )
static

Definition at line 457 of file date.c.

458 {
459  FILETIME ftime;
460  LONGLONG time;
461 
463  time = ((LONGLONG)ftime.dwHighDateTime << 32) + ftime.dwLowDateTime;
464 
465  return time/10000 - TIME_EPOCH;
466 }
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:34

Referenced by DateConstr_now(), and DateConstr_value().

◆ date_parse()

static HRESULT date_parse ( jsstr_t input_str,
double ret 
)
inlinestatic

Definition at line 2032 of file date.c.

2032  {
2033  static const DWORD string_ids[] = { LOCALE_SMONTHNAME12, LOCALE_SMONTHNAME11,
2040  WCHAR *strings[ARRAY_SIZE(string_ids)];
2041  WCHAR *parse;
2042  int input_len, parse_len = 0, nest_level = 0, i, size;
2043  int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
2044  int ms = 0, offset = 0, hour_adjust = 0;
2045  BOOL set_year = FALSE, set_month = FALSE, set_day = FALSE, set_hour = FALSE;
2046  BOOL set_offset = FALSE, set_era = FALSE, ad = TRUE, set_am = FALSE, am = TRUE;
2047  BOOL set_hour_adjust = TRUE;
2049  const WCHAR *input;
2050  DateInstance di;
2051  DWORD lcid_en;
2052 
2053  input_len = jsstr_length(input_str);
2054  input = jsstr_flatten(input_str);
2055  if(!input)
2056  return E_OUTOFMEMORY;
2057 
2058  for(i=0; i<input_len; i++) {
2059  if(input[i] == '(') nest_level++;
2060  else if(input[i] == ')') {
2061  nest_level--;
2062  if(nest_level<0) {
2063  *ret = NAN;
2064  return S_OK;
2065  }
2066  }
2067  else if(!nest_level) parse_len++;
2068  }
2069 
2070  parse = heap_alloc((parse_len+1)*sizeof(WCHAR));
2071  if(!parse)
2072  return E_OUTOFMEMORY;
2073  nest_level = 0;
2074  parse_len = 0;
2075  for(i=0; i<input_len; i++) {
2076  if(input[i] == '(') nest_level++;
2077  else if(input[i] == ')') nest_level--;
2078  else if(!nest_level) parse[parse_len++] = toupperW(input[i]);
2079  }
2080  parse[parse_len] = 0;
2081 
2082  GetTimeZoneInformation(&tzi);
2083  di.bias = tzi.Bias;
2084  di.standardDate = tzi.StandardDate;
2085  di.standardBias = tzi.StandardBias;
2086  di.daylightDate = tzi.DaylightDate;
2087  di.daylightBias = tzi.DaylightBias;
2088 
2089  /* FIXME: Cache strings */
2091  for(i=0; i<ARRAY_SIZE(string_ids); i++) {
2092  size = GetLocaleInfoW(lcid_en, string_ids[i], NULL, 0);
2093  strings[i] = heap_alloc((size+1)*sizeof(WCHAR));
2094  if(!strings[i]) {
2095  i--;
2096  while(i-- >= 0)
2097  heap_free(strings[i]);
2098  heap_free(parse);
2099  return E_OUTOFMEMORY;
2100  }
2101  GetLocaleInfoW(lcid_en, string_ids[i], strings[i], size);
2102  }
2103 
2104  for(i=0; i<parse_len;) {
2105  while(isspaceW(parse[i])) i++;
2106  if(parse[i] == ',') {
2107  while(parse[i] == ',') i++;
2108  continue;
2109  }
2110 
2111  if(parse[i]>='0' && parse[i]<='9') {
2112  int tmp = atoiW(&parse[i]);
2113  while(parse[i]>='0' && parse[i]<='9') i++;
2114  while(isspaceW(parse[i])) i++;
2115 
2116  if(parse[i] == ':') {
2117  /* Time */
2118  if(set_hour) break;
2119  set_hour = TRUE;
2120 
2121  hour = tmp;
2122 
2123  while(parse[i] == ':') i++;
2124  while(isspaceW(parse[i])) i++;
2125  if(parse[i]>='0' && parse[i]<='9') {
2126  min = atoiW(&parse[i]);
2127  while(parse[i]>='0' && parse[i]<='9') i++;
2128  }
2129 
2130  while(isspaceW(parse[i])) i++;
2131  while(parse[i] == ':') i++;
2132  while(isspaceW(parse[i])) i++;
2133  if(parse[i]>='0' && parse[i]<='9') {
2134  sec = atoiW(&parse[i]);
2135  while(parse[i]>='0' && parse[i]<='9') i++;
2136  }
2137  }
2138  else if(parse[i]=='-' || parse[i]=='/') {
2139  /* Short or long date */
2140  if(set_day || set_month || set_year) break;
2141  set_day = TRUE;
2142  set_month = TRUE;
2143  set_year = TRUE;
2144 
2145  month = tmp-1;
2146 
2147  while(isspaceW(parse[i])) i++;
2148  while(parse[i]=='-' || parse[i]=='/') i++;
2149  while(isspaceW(parse[i])) i++;
2150  if(parse[i]<'0' || parse[i]>'9') break;
2151  day = atoiW(&parse[i]);
2152  while(parse[i]>='0' && parse[i]<='9') i++;
2153 
2154  while(parse[i]=='-' || parse[i]=='/') i++;
2155  while(isspaceW(parse[i])) i++;
2156  if(parse[i]<'0' || parse[i]>'9') break;
2157  year = atoiW(&parse[i]);
2158  while(parse[i]>='0' && parse[i]<='9') i++;
2159 
2160  if(tmp >= 70){
2161  /* long date */
2162  month = day - 1;
2163  day = year;
2164  year = tmp;
2165  }
2166  }
2167  else if(tmp<0) break;
2168  else if(tmp<70) {
2169  /* Day */
2170  if(set_day) break;
2171  set_day = TRUE;
2172  day = tmp;
2173  }
2174  else {
2175  /* Year */
2176  if(set_year) break;
2177  set_year = TRUE;
2178  year = tmp;
2179  }
2180  }
2181  else if(parse[i]=='+' || parse[i]=='-') {
2182  /* Timezone offset */
2183  BOOL positive = TRUE;
2184 
2185  if(set_offset && set_hour_adjust) break;
2186  set_offset = TRUE;
2187  set_hour_adjust = FALSE;
2188 
2189  if(parse[i] == '-') positive = FALSE;
2190 
2191  i++;
2192  while(isspaceW(parse[i])) i++;
2193  if(parse[i]<'0' || parse[i]>'9') break;
2194  offset = atoiW(&parse[i]);
2195  while(parse[i]>='0' && parse[i]<='9') i++;
2196 
2197  if(offset<24) offset *= 60;
2198  else offset = (offset/100)*60 + offset%100;
2199 
2200  if(positive) offset = -offset;
2201 
2202  }
2203  else {
2204  if(parse[i]<'A' || parse[i]>'Z') break;
2205  else if(parse[i]=='B' && (parse[i+1]=='C' ||
2206  (parse[i+1]=='.' && parse[i+2]=='C'))) {
2207  /* AD/BC */
2208  if(set_era) break;
2209  set_era = TRUE;
2210  ad = FALSE;
2211 
2212  i++;
2213  if(parse[i] == '.') i++;
2214  i++;
2215  if(parse[i] == '.') i++;
2216  }
2217  else if(parse[i]=='A' && (parse[i+1]=='D' ||
2218  (parse[i+1]=='.' && parse[i+2]=='D'))) {
2219  /* AD/BC */
2220  if(set_era) break;
2221  set_era = TRUE;
2222 
2223  i++;
2224  if(parse[i] == '.') i++;
2225  i++;
2226  if(parse[i] == '.') i++;
2227  }
2228  else if(parse[i+1]<'A' || parse[i+1]>'Z') {
2229  /* Timezone */
2230  if(set_offset) break;
2231  set_offset = TRUE;
2232 
2233  if(parse[i] <= 'I') hour_adjust = parse[i]-'A'+2;
2234  else if(parse[i] == 'J') break;
2235  else if(parse[i] <= 'M') hour_adjust = parse[i]-'K'+11;
2236  else if(parse[i] <= 'Y') hour_adjust = parse[i]-'N';
2237  else hour_adjust = 1;
2238 
2239  i++;
2240  if(parse[i] == '.') i++;
2241  }
2242  else if(parse[i]=='A' && parse[i+1]=='M') {
2243  /* AM/PM */
2244  if(set_am) break;
2245  set_am = TRUE;
2246  am = TRUE;
2247  i += 2;
2248  }
2249  else if(parse[i]=='P' && parse[i+1]=='M') {
2250  /* AM/PM */
2251  if(set_am) break;
2252  set_am = TRUE;
2253  am = FALSE;
2254  i += 2;
2255  }
2256  else if((parse[i]=='U' && parse[i+1]=='T' && parse[i+2]=='C')
2257  || (parse[i]=='G' && parse[i+1]=='M' && parse[i+2]=='T')) {
2258  /* Timezone */
2259  if(set_offset) break;
2260  set_offset = TRUE;
2261  set_hour_adjust = FALSE;
2262 
2263  i += 3;
2264  }
2265  else {
2266  /* Month or garbage */
2267  unsigned int j;
2268 
2269  for(size=i; parse[size]>='A' && parse[size]<='Z'; size++);
2270  size -= i;
2271 
2272  for(j=0; j<ARRAY_SIZE(string_ids); j++)
2273  if(!strncmpiW(&parse[i], strings[j], size)) break;
2274 
2275  if(j < 12) {
2276  if(set_month) break;
2277  set_month = TRUE;
2278  month = 11-j;
2279  }
2280  else if(j == ARRAY_SIZE(string_ids)) break;
2281 
2282  i += size;
2283  }
2284  }
2285  }
2286 
2287  if(i == parse_len && set_year && set_month && set_day && (!set_am || hour<13)) {
2288  if(set_am) {
2289  if(hour == 12) hour = 0;
2290  if(!am) hour += 12;
2291  }
2292 
2293  if(!ad) year = -year+1;
2294  else if(year<100) year += 1900;
2295 
2296  *ret = time_clip(make_date(make_day(year, month, day),
2297  make_time(hour+hour_adjust, min, sec, ms)) + offset*MS_PER_MINUTE);
2298 
2299  if(set_hour_adjust)
2300  *ret = utc(*ret, &di);
2301  }else {
2302  *ret = NAN;
2303  }
2304 
2305  for(i=0; i<ARRAY_SIZE(string_ids); i++)
2306  heap_free(strings[i]);
2307  heap_free(parse);
2308 
2309  return S_OK;
2310 }
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:46
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static DOUBLE day(DOUBLE time)
Definition: date.c:115
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
GLintptr offset
Definition: glext.h:5920
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:424
#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:44
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:112
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
WINE_UNICODE_INLINE WCHAR toupperW(WCHAR ch)
Definition: unicode.h:141
SYSTEMTIME standardDate
Definition: date.c:43
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
SYSTEMTIME daylightDate
Definition: date.c:45
#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
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:1161
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:355
#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:42
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define MAKELANGID(p, s)
Definition: nls.h:15
int month[12]
Definition: systime.c:13
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
SYSTEMTIME DaylightDate
Definition: winbase.h:1164
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
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 1636 of file date.c.

1638 {
1639  DateInstance *date;
1640  double t, n;
1641  HRESULT hres;
1642 
1643  TRACE("\n");
1644 
1645  if(!(date = date_this(jsthis)))
1647 
1648  if(!argc)
1649  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1650 
1651  hres = to_number(ctx, argv[0], &n);
1652  if(FAILED(hres))
1653  return hres;
1654 
1655  t = local_time(date->time, date);
1657  date->time = time_clip(utc(t, date));
1658 
1659  if(r)
1660  *r = jsval_number(date->time);
1661  return S_OK;
1662 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:349
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:227
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
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 1772 of file date.c.

1774 {
1775  DateInstance *date;
1776  double t, year, month, ddate;
1777  HRESULT hres;
1778 
1779  TRACE("\n");
1780 
1781  if(!(date = date_this(jsthis)))
1783 
1784  if(!argc)
1785  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1786 
1787  t = local_time(date->time, date);
1788 
1789  hres = to_number(ctx, argv[0], &year);
1790  if(FAILED(hres))
1791  return hres;
1792 
1793  if(argc > 1) {
1794  hres = to_number(ctx, argv[1], &month);
1795  if(FAILED(hres))
1796  return hres;
1797  }else {
1798  month = month_from_time(t);
1799  }
1800 
1801  if(argc > 2) {
1802  hres = to_number(ctx, argv[2], &ddate);
1803  if(FAILED(hres))
1804  return hres;
1805  }else {
1806  ddate = date_from_time(t);
1807  }
1808 
1809  t = make_date(make_day(year, month, ddate), time_within_day(t));
1810  date->time = time_clip(utc(t, date));
1811 
1812  if(r)
1813  *r = jsval_number(date->time);
1814  return S_OK;
1815 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:349
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:227
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
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 1528 of file date.c.

1530 {
1531  DateInstance *date;
1532  double t, hour, min, sec, ms;
1533  HRESULT hres;
1534 
1535  TRACE("\n");
1536 
1537  if(!(date = date_this(jsthis)))
1539 
1540  if(!argc)
1541  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1542 
1543  t = local_time(date->time, date);
1544 
1545  hres = to_number(ctx, argv[0], &hour);
1546  if(FAILED(hres))
1547  return hres;
1548 
1549  if(argc > 1) {
1550  hres = to_number(ctx, argv[1], &min);
1551  if(FAILED(hres))
1552  return hres;
1553  }else {
1554  min = min_from_time(t);
1555  }
1556 
1557  if(argc > 2) {
1558  hres = to_number(ctx, argv[2], &sec);
1559  if(FAILED(hres))
1560  return hres;
1561  }else {
1562  sec = sec_from_time(t);
1563  }
1564 
1565  if(argc > 3) {
1566  hres = to_number(ctx, argv[3], &ms);
1567  if(FAILED(hres))
1568  return hres;
1569  }else {
1570  ms = ms_from_time(t);
1571  }
1572 
1573  t = make_date(day(t), make_time(hour, min, sec, ms));
1574  date->time = time_clip(utc(t, date));
1575 
1576  if(r)
1577  *r = jsval_number(date->time);
1578  return S_OK;
1579 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1296 of file date.c.

1298 {
1299  DateInstance *date;
1300  double n, t;
1301  HRESULT hres;
1302 
1303  TRACE("\n");
1304 
1305  if(!(date = date_this(jsthis)))
1307 
1308  if(!argc)
1309  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1310 
1311  hres = to_number(ctx, argv[0], &n);
1312  if(FAILED(hres))
1313  return hres;
1314 
1315  t = local_time(date->time, date);
1317  sec_from_time(t), n));
1318  date->time = time_clip(utc(t, date));
1319 
1320  if(r)
1321  *r = jsval_number(date->time);
1322  return S_OK;
1323 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1434 of file date.c.

1436 {
1437  DateInstance *date;
1438  double t, min, sec, ms;
1439  HRESULT hres;
1440 
1441  TRACE("\n");
1442 
1443  if(!(date = date_this(jsthis)))
1445 
1446  if(!argc)
1447  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1448 
1449  t = local_time(date->time, date);
1450 
1451  hres = to_number(ctx, argv[0], &min);
1452  if(FAILED(hres))
1453  return hres;
1454 
1455  if(argc > 1) {
1456  hres = to_number(ctx, argv[1], &sec);
1457  if(FAILED(hres))
1458  return hres;
1459  }else {
1460  sec = sec_from_time(t);
1461  }
1462 
1463  if(argc > 2) {
1464  hres = to_number(ctx, argv[2], &ms);
1465  if(FAILED(hres))
1466  return hres;
1467  }else {
1468  ms = ms_from_time(t);
1469  }
1470 
1472  min, sec, ms));
1473  date->time = time_clip(utc(t, date));
1474 
1475  if(r)
1476  *r = jsval_number(date->time);
1477  return S_OK;
1478 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1694 of file date.c.

1696 {
1697  DateInstance *date;
1698  DOUBLE t, month, ddate;
1699  HRESULT hres;
1700 
1701  TRACE("\n");
1702 
1703  if(!(date = date_this(jsthis)))
1705 
1706  if(!argc)
1707  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1708 
1709  t = local_time(date->time, date);
1710 
1711  hres = to_number(ctx, argv[0], &month);
1712  if(FAILED(hres))
1713  return hres;
1714 
1715  if(argc > 1) {
1716  hres = to_number(ctx, argv[1], &ddate);
1717  if(FAILED(hres))
1718  return hres;
1719  }else {
1720  ddate = date_from_time(t);
1721  }
1722 
1723  t = make_date(make_day(year_from_time(t), month, ddate),
1724  time_within_day(t));
1725  date->time = time_clip(utc(t, date));
1726 
1727  if(r)
1728  *r = jsval_number(date->time);
1729  return S_OK;
1730 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:349
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__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:438
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 1356 of file date.c.

1358 {
1359  DateInstance *date;
1360  double t, sec, ms;
1361  HRESULT hres;
1362 
1363  TRACE("\n");
1364 
1365  if(!(date = date_this(jsthis)))
1367 
1368  if(!argc)
1369  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1370 
1371  t = local_time(date->time, date);
1372 
1373  hres = to_number(ctx, argv[0], &sec);
1374  if(FAILED(hres))
1375  return hres;
1376 
1377  if(argc > 1) {
1378  hres = to_number(ctx, argv[1], &ms);
1379  if(FAILED(hres))
1380  return hres;
1381  }else {
1382  ms = ms_from_time(t);
1383  }
1384 
1386  min_from_time(t), sec, ms));
1387  date->time = time_clip(utc(t, date));
1388 
1389  if(r)
1390  *r = jsval_number(date->time);
1391  return S_OK;
1392 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
GLdouble GLdouble t
Definition: gl.h:2047
static DOUBLE local_time(DOUBLE time, DateInstance *date)
Definition: date.c:349
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1269 of file date.c.

1271 {
1272  double n;
1273  HRESULT hres;
1274  DateInstance *date;
1275 
1276  TRACE("\n");
1277 
1278  if(!(date = date_this(jsthis)))
1280 
1281  if(!argc)
1282  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1283 
1284  hres = to_number(ctx, argv[0], &n);
1285  if(FAILED(hres))
1286  return hres;
1287 
1288  date->time = time_clip(n);
1289 
1290  if(r)
1291  *r = jsval_number(date->time);
1292  return S_OK;
1293 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:438
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 1665 of file date.c.

1667 {
1668  DateInstance *date;
1669  double t, n;
1670  HRESULT hres;
1671 
1672  TRACE("\n");
1673 
1674  if(!(date = date_this(jsthis)))
1676 
1677  if(!argc)
1678  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1679 
1680  hres = to_number(ctx, argv[0], &n);
1681  if(FAILED(hres))
1682  return hres;
1683 
1684  t = date->time;
1686  date->time = time_clip(t);
1687 
1688  if(r)
1689  *r = jsval_number(date->time);
1690  return S_OK;
1691 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:227
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:438
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 1818 of file date.c.

1820 {
1821  DateInstance *date;
1822  double t, year, month, ddate;
1823  HRESULT hres;
1824 
1825  TRACE("\n");
1826 
1827  if(!(date = date_this(jsthis)))
1829 
1830  if(!argc)
1831  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1832 
1833  t = date->time;
1834 
1835  hres = to_number(ctx, argv[0], &year);
1836  if(FAILED(hres))
1837  return hres;
1838 
1839  if(argc > 1) {
1840  hres = to_number(ctx, argv[1], &month);
1841  if(FAILED(hres))
1842  return hres;
1843  }else {
1844  month = month_from_time(t);
1845  }
1846 
1847  if(argc > 2) {
1848  hres = to_number(ctx, argv[2], &ddate);
1849  if(FAILED(hres))
1850  return hres;
1851  }else {
1852  ddate = date_from_time(t);
1853  }
1854 
1855  t = make_date(make_day(year, month, ddate), time_within_day(t));
1856  date->time = time_clip(t);
1857 
1858  if(r)
1859  *r = jsval_number(date->time);
1860  return S_OK;
1861 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:227
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:438
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 1582 of file date.c.

1584 {
1585  DateInstance *date;
1586  double t, hour, min, sec, ms;
1587  HRESULT hres;
1588 
1589  TRACE("\n");
1590 
1591  if(!(date = date_this(jsthis)))
1593 
1594  if(!argc)
1595  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1596 
1597  t = date->time;
1598 
1599  hres = to_number(ctx, argv[0], &hour);
1600  if(FAILED(hres))
1601  return hres;
1602 
1603  if(argc > 1) {
1604  hres = to_number(ctx, argv[1], &min);
1605  if(FAILED(hres))
1606  return hres;
1607  }else {
1608  min = min_from_time(t);
1609  }
1610 
1611  if(argc > 2) {
1612  hres = to_number(ctx, argv[2], &sec);
1613  if(FAILED(hres))
1614  return hres;
1615  }else {
1616  sec = sec_from_time(t);
1617  }
1618 
1619  if(argc > 3) {
1620  hres = to_number(ctx, argv[3], &ms);
1621  if(FAILED(hres))
1622  return hres;
1623  }else {
1624  ms = ms_from_time(t);
1625  }
1626 
1627  t = make_date(day(t), make_time(hour, min, sec, ms));
1628  date->time = time_clip(t);
1629 
1630  if(r)
1631  *r = jsval_number(date->time);
1632  return S_OK;
1633 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
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:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1326 of file date.c.

1328 {
1329  DateInstance *date;
1330  double n, t;
1331  HRESULT hres;
1332 
1333  TRACE("\n");
1334 
1335  if(!(date = date_this(jsthis)))
1337 
1338  if(!argc)
1339  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1340 
1341  hres = to_number(ctx, argv[0], &n);
1342  if(FAILED(hres))
1343  return hres;
1344 
1345  t = date->time;
1347  sec_from_time(t), n));
1348  date->time = time_clip(t);
1349 
1350  if(r)
1351  *r = jsval_number(date->time);
1352  return S_OK;
1353 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
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:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:442
#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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1481 of file date.c.

1483 {
1484  DateInstance *date;
1485  double t, min, sec, ms;
1486  HRESULT hres;
1487 
1488  TRACE("\n");
1489 
1490  if(!(date = date_this(jsthis)))
1492 
1493  if(!argc)
1494  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1495 
1496  t = date->time;
1497 
1498  hres = to_number(ctx, argv[0], &min);
1499  if(FAILED(hres))
1500  return hres;
1501 
1502  if(argc > 1) {
1503  hres = to_number(ctx, argv[1], &sec);
1504  if(FAILED(hres))
1505  return hres;
1506  }else {
1507  sec = sec_from_time(t);
1508  }
1509 
1510  if(argc > 2) {
1511  hres = to_number(ctx, argv[2], &ms);
1512  if(FAILED(hres))
1513  return hres;
1514  }else {
1515  ms = ms_from_time(t);
1516  }
1517 
1519  min, sec, ms));
1520  date->time = time_clip(t);
1521 
1522  if(r)
1523  *r = jsval_number(date->time);
1524  return S_OK;
1525 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
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:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1733 of file date.c.

1735 {
1736  DateInstance *date;
1737  double t, month, ddate;
1738  HRESULT hres;
1739 
1740  TRACE("\n");
1741 
1742  if(!(date = date_this(jsthis)))
1744 
1745  if(!argc)
1746  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1747 
1748  t = date->time;
1749 
1750  hres = to_number(ctx, argv[0], &month);
1751  if(FAILED(hres))
1752  return hres;
1753 
1754  if(argc > 1) {
1755  hres = to_number(ctx, argv[1], &ddate);
1756  if(FAILED(hres))
1757  return hres;
1758  }else {
1759  ddate = date_from_time(t);
1760  }
1761 
1762  t = make_date(make_day(year_from_time(t), month, ddate),
1763  time_within_day(t));
1764  date->time = time_clip(t);
1765 
1766  if(r)
1767  *r = jsval_number(date->time);
1768  return S_OK;
1769 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:442
#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:438
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 1395 of file date.c.

1397 {
1398  DateInstance *date;
1399  double t, sec, ms;
1400  HRESULT hres;
1401 
1402  TRACE("\n");
1403 
1404  if(!(date = date_this(jsthis)))
1406 
1407  if(!argc)
1408  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1409 
1410  t = date->time;
1411 
1412  hres = to_number(ctx, argv[0], &sec);
1413  if(FAILED(hres))
1414  return hres;
1415 
1416  if(argc > 1) {
1417  hres = to_number(ctx, argv[1], &ms);
1418  if(FAILED(hres))
1419  return hres;
1420  }else {
1421  ms = ms_from_time(t);
1422  }
1423 
1425  min_from_time(t), sec, ms));
1426  date->time = time_clip(t);
1427 
1428  if(r)
1429  *r = jsval_number(date->time);
1430  return S_OK;
1431 }
static DOUBLE min_from_time(DOUBLE time)
Definition: date.c:376
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static DOUBLE day(DOUBLE time)
Definition: date.c:115
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:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE hour_from_time(DOUBLE time)
Definition: date.c:362
#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:404
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
#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:438
static DOUBLE make_time(DOUBLE hour, DOUBLE min, DOUBLE sec, DOUBLE ms)
Definition: date.c:418
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 1889 of file date.c.

1891 {
1892  DateInstance *date;
1893  DOUBLE t, year;
1894  HRESULT hres;
1895 
1896  TRACE("\n");
1897 
1898  if(!(date = date_this(jsthis)))
1900 
1901  if(!argc)
1902  return throw_type_error(ctx, JS_E_MISSING_ARG, NULL);
1903 
1904  t = local_time(date->time, date);
1905 
1906  hres = to_number(ctx, argv[0], &year);
1907  if(FAILED(hres))
1908  return hres;
1909 
1910  if(isnan(year)) {
1911  date->time = year;
1912  if(r)
1913  *r = jsval_number(NAN);
1914  return S_OK;
1915  }
1916 
1917  year = year >= 0.0 ? floor(year) : -floor(-year);
1918  if(-1.0 < year && year < 100.0)
1919  year += 1900.0;
1920 
1922 
1923  if(r)
1924  *r = jsval_number(date->time);
1925  return S_OK;
1926 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
#define JS_E_MISSING_ARG
Definition: jscript.h:536
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:349
#define argv
Definition: mplay32.c:18
static DOUBLE make_day(DOUBLE year, DOUBLE month, DOUBLE day)
Definition: date.c:424
static DOUBLE time_within_day(DOUBLE time)
Definition: date.c:121
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static DOUBLE time_clip(DOUBLE time)
Definition: date.c:448
smooth NULL
Definition: ftsmooth.c:416
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
#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:227
static DOUBLE make_date(DOUBLE day, DOUBLE time)
Definition: date.c:442
int isnan(double x)
#define S_OK
Definition: intsafe.h:59
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:355
__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:438
_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 484 of file date.c.

485 {
486  static const WCHAR formatW[] = { '%','s',' ','%','s',' ','%','d',' ',
487  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ',
488  'U','T','C','%','c','%','0','2','d','%','0','2','d',' ','%','d','%','s',0 };
489  static const WCHAR formatUTCW[] = { '%','s',' ','%','s',' ','%','d',' ',
490  '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ',
491  'U','T','C',' ','%','d','%','s',0 };
492  static const WCHAR formatNoOffsetW[] = { '%','s',' ','%','s',' ',
493  '%','d',' ','%','0','2','d',':','%','0','2','d',':',
494  '%','0','2','d',' ','%','d','%','s',0 };
495  static const WCHAR ADW[] = { 0 };
496  static const WCHAR BCW[] = { ' ','B','.','C','.',0 };
497 
498  static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1,
501  static const DWORD month_ids[] = { LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2,
507 
508  BOOL formatAD = TRUE;
509  WCHAR week[64], month[64];
510  WCHAR buf[192];
511  jsstr_t *date_jsstr;
512  int year, day;
513  DWORD lcid_en;
514  WCHAR sign = '-';
515 
516  if(isnan(time)) {
517  if(r)
518  *r = jsval_string(jsstr_nan());
519  return S_OK;
520  }
521 
522  if(r) {
524 
525  week[0] = 0;
526  GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, ARRAY_SIZE(week));
527 
528  month[0] = 0;
529  GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, ARRAY_SIZE(month));
530 
531  year = year_from_time(time);
532  if(year<0) {
533  formatAD = FALSE;
534  year = -year+1;
535  }
536 
538 
539  if(offset < 0) {
540  sign = '+';
541  offset = -offset;
542  }
543 
544  if(!show_offset)
545  sprintfW(buf, formatNoOffsetW, week, month, day,
546  (int)hour_from_time(time), (int)min_from_time(time),
547  (int)sec_from_time(time), year, formatAD?ADW:BCW);
548  else if(offset)
549  sprintfW(buf, formatW, week, month, day,
550  (int)hour_from_time(time), (int)min_from_time(time),
551  (int)sec_from_time(time), sign, offset/60, offset%60,
552  year, formatAD?ADW:BCW);
553  else
554  sprintfW(buf, formatUTCW, week, month, day,
555  (int)hour_from_time(time), (int)min_from_time(time),
556  (int)sec_from_time(time), year, formatAD?ADW:BCW);
557 
558  date_jsstr = jsstr_alloc(buf);
559  if(!date_jsstr)
560  return E_OUTOFMEMORY;
561 
562  *r = jsval_string(date_jsstr);
563  }
564  return S_OK;
565 }
static size_t double int int int * sign
Definition: printf.c:64
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:376
#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:274
static DOUBLE sec_from_time(DOUBLE time)
Definition: date.c:390
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
Definition: jsstr.h:39
static DOUBLE year_from_time(DOUBLE time)
Definition: date.c:195
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:115
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:362
static DOUBLE date_from_time(DOUBLE time)
Definition: date.c:250
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
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:227
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 sprintfW
Definition: unicode.h:58
#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 836 of file date.c.

838 {
840 
841  if(!(date = date_this(jsthis)))
843 
844  return dateobj_to_date_string(date, r);
845 }
#define JS_E_DATE_EXPECTED
Definition: jscript.h:554
static DateInstance * date_this(vdisp_t *jsthis)
Definition: date.c:104
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:777
__u16 date
Definition: mkdosfs.c:366
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438

◆ 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 769 of file date.c.

771 {
772  TRACE("\n");
773  return create_utc_string(ctx, jsthis, r);
774 }
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:697

◆ 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 636 of file date.c.

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