Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34769
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? |
| Date | 2018-03-12 19:01 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnpadjke.31p.jon+usenet@sable.unequivocal.eu> (permalink) |
| References | <928d7c15-93f7-46e3-b5ee-78cb19ae02d1@googlegroups.com> |
On 2018-03-12, Dr J R Stockton <J.R.Stockton@physics.org> wrote:
> At present, the second Sunday of March having started, when running
> JScript in Windows (7 & 10) Script Host in the UK after 23:00 LCT,
> D = new Date() thinks that it is tomorrow already, which upsets my
> "show today's files" logic. The reason is that WSH believes that the
> UK uses the US DST clock rules. I expect the fault to go away on
> the last Sunday of March, and to reappear for a week from the last
> Sunday of October, etc.
>
> I believe that the same root error will occur in other places using
> EU Summer Time Rules - and it could occur elsewhere.
>
> So I want to fix the root problem by using, instead of "new Date()"
> a new function "NewDate()" which will get the date from the MS-DOS
> environment variable %date% or by executing the MS-DOS DIR command.
>
> Does anyone here know how to write that new function (and, if so,
> please demonstrate)? I have reason to think that it can be done
> using non-ECMA calls within WSH.
This seems to work for me:
var WshShell = new ActiveXObject('WScript.Shell')
var aDate = WshShell.Exec('cmd /c echo %date%').StdOut.ReadLine().split('/')
var dDate = new Date(aDate[2], aDate[1] - 1, aDate[0])
Mind you, just 'new Date()' seems to be working for me anyway.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-12 11:26 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-12 19:01 +0000
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-12 16:01 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-13 12:06 +0000
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-03-13 13:19 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-14 13:29 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Julio Di Egidio <julio@diegidio.name> - 2018-03-14 14:18 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 02:19 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 02:35 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-15 11:38 +0000
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 13:37 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-15 23:24 +0000
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-16 14:14 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-16 23:34 +0000
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-04-18 03:15 -0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? JJ <jj4public@vfemail.net> - 2018-04-18 22:58 +0700
Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Julio Di Egidio <julio@diegidio.name> - 2018-03-15 10:50 -0700
csiph-web