By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Automating date/time input for modem/router

P: n/a
My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).

The router's IP address is 10.1.1.1. AIUI, all relative addresses in
the PopOutPage would need to be changed to reflect this..

The date/time input code is accessed via this URL:
http://10.1.1.1/PopOutPage?id=3&ex_param1=

The source code for the above JS form is here:
http://www.users.on.net/~fzabkar/DSL...PopOutPage.htm

The above form calls these .gsv and .css files:
http://10.1.1.1/hag/js/global.gsv
http://10.1.1.1/hag/css/style.css

The respective source code is here:
http://www.users.on.net/~fzabkar/DSL-302G/global.gsv
http://www.users.on.net/~fzabkar/DSL-302G/style.css

Thanks in advance for any pointers.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 2 '06 #1
Share this Question
Share on Google+
17 Replies


P: n/a
On Thu, 02 Feb 2006 14:55:09 +1100, Franc Zabkar
<fz*****@iinternode.on.net> put finger to keyboard and composed:
My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).


OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 2 '06 #2

P: n/a
Franc Zabkar wrote:
I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".
One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");
Thanks in advance for any assistance.


RTFM next time.
PointedEars
Feb 2 '06 #3

P: n/a
JRS: In article <qe********************************@4ax.com>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in news:comp.lang.javascript,
Franc Zabkar <fz*****@iinternode.on.net> posted :

OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...ys_year=2005&s
ysm_time_check=&sys_hour=22&sys_minute=2&sys_seco nd=22&timezone_combo=42&dst=1&h
ost_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.


Did you consider reading the newsgroup FAQ before posting? See sig
below.

EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.

You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.

Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 3 '06 #4

P: n/a
On Fri, 3 Feb 2006 13:20:32 +0000, Dr John Stockton
<jr*@merlyn.demon.co.uk> put finger to keyboard and composed:
JRS: In article <qe********************************@4ax.com>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in news:comp.lang.javascript,
Franc Zabkar <fz*****@iinternode.on.net> posted :

OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...ys_year=2005&s
ysm_time_check=&sys_hour=22&sys_minute=2&sys_sec ond=22&timezone_combo=42&dst=1&h
ost_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.
Did you consider reading the newsgroup FAQ before posting? See sig
below.


Sorry, I did not. The reason is that I have absolutely *no*
prerequisite knowledge of HTML, JS, or C, and I don't foresee any
pressing need for same. In any case, I have two books on JS, but they
both assume a working knowledge of HTML.

Anyway I thought the answer would be simple enough, and indeed it was.
While it isn't pretty, here is my solution (using input from this NG):

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm
EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.
I have no control over this because it is built into the modem's
firmware. In any case I don't consider timezone_combo as a true
variable because this setting can be saved in the modem's nonvolatile
memory. The user can preset his own choice in the abovementioned JS
script. Indeed, it would be impossible to programmatically select the
preferred timezone_combo given that some system time zones can map to
several timezone_combo options, eg:

20 CET +0100 Central European
21 FWT +0100 French Winter
22 MET +0100 Middle European
23 MEWT +0100 Middle European Winter
24 SWT +0100 Swedish Winter
You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.
This code is purely for my own convenience. The *only* reason that I
wish to synchronise the modem's date and time is so that I can make
sense of the modem's event log. I really don't care too much about the
time zone, or whether daylight is being saved. Therefore I am quite
happy to hard-code the TZ and DST parameters. In any case these
parameters can be retained by the modem's nonvolatile memory and need
not be updated.

Perhaps this log of PPP events will illustrate the problem:

http://www.users.on.net/~fzabkar/DSL-302G/Alarms.htm

Notice that when the modem first powers up and connects to the DSLAM,
the date and time are those which are retrieved from the modem's
nonvolatile memory:

================================================== ====================
Sat Sep 03 20:09:11 2005 : STATUS ALARM : ATM Interface Up : Interface
- atm-0
Sat Sep 03 20:09:11 2005 : STATUS ALARM : DSL Interface Up
Sat Sep 03 20:09:01 2005 : STATUS ALARM : System Up
================================================== ====================

I believe that "Sat Sep 03" was the date when I last saved the modem's
configuration settings, ie PPP, Bridging, LAN, WAN, Admin.

After synchronising the date/time, the log looks like this:

================================================== ====================
Sat Feb 04 19:02:42 2006 : STATUS ALARM : PPP Interface Up : Interface
- ppp-0
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got secondary
DNS address: 192.231.203.3
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got primary
DNS address: 192.231.203.132
================================================== ====================
Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!


Again, this is a function of the modem's firmware. It is of no real
interest to me as I don't work past midnight and I switch off the
modem when I'm done. I may experiment with this parameter, though,
just out of curiosity. When I find out how it works I'll add an
appropriate comment to the TimeSync routine.

Thanks for your input.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 5 '06 #5

P: n/a
On Thu, 02 Feb 2006 21:24:41 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> put finger to keyboard and composed:
Franc Zabkar wrote:
I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit
The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".


One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");
Thanks in advance for any assistance.


RTFM next time.


Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult a
dictionary.

Anyway, after a considerable struggle, I came up with this:

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm
PointedEars


- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 5 '06 #6

P: n/a
Franc Zabkar wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote: [Full quote]


Read the FAQ and the FAQ Notes before you post here again.
RTFM next time.


Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.


The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.
PointedEars
Feb 5 '06 #7

P: n/a
Franc Zabkar wrote:
[...] Anyway, after a considerable struggle, I came up with this:
Considerable struggle? Your code is essentially mine, without even
mentioning it!
http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm


Hopefully you aware that you will probably set the wrong time half
of the year.
PointedEars
Feb 5 '06 #8

P: n/a
On Sun, 05 Feb 2006 17:48:44 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> put finger to keyboard and composed:
Franc Zabkar wrote:
[...] Anyway, after a considerable struggle, I came up with this:
Considerable struggle?


My difficulty was not so much in creating a variable, although I would
have done it in a much less elegant way (by using a long concatenation
statement). The main problem was in breaking down several pages of
completely unfamiliar code into a basic requirement, and then finding
a way to direct my browser to a variable URL. Neither of my JS texts
addressed the latter, most important need.
Your code is essentially mine, without even mentioning it!


I had considered acknowledging your var statement by way of a comment
within the body of the code, but wasn't sure whether this would be
deemed too trivial. No disrespect intended.
http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm


Hopefully you aware that you will probably set the wrong time half
of the year.


Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight. Perhaps it would be
safer to specify "&dst=0", though, just in case the modem firmware
hard codes some other transition date.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 6 '06 #9

P: n/a
On Sun, 05 Feb 2006 16:17:03 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> put finger to keyboard and composed:
Franc Zabkar wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:

[Full quote]


Read the FAQ and the FAQ Notes before you post here again.
RTFM next time.


Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.


The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.


OK, your criticisms are acknowledged and accepted. I'm at page 70 of
chapter 6 of "Javascript by Example" and still reading ...

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 6 '06 #10

P: n/a
On 2006-02-06, Franc Zabkar <fz*****@iinternode.on.net> wrote:
Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight.


midnight?

--

Bye.
Jasen
Feb 7 '06 #11

P: n/a
Franc Zabkar wrote:
[...] Thomas 'PointedEars' Lahn [wrote]:
Franc Zabkar wrote:
[...] Anyway, after a considerable struggle, I came up with this: Considerable struggle?


[...] The main problem was in breaking down several pages of
completely unfamiliar code into a basic requirement, and then finding
a way to direct my browser to a variable URL. Neither of my JS texts
addressed the latter, most important need.
Your code is essentially mine, without even mentioning it!


I had considered acknowledging your var statement by way of a comment
within the body of the code, but wasn't sure whether this would be
deemed too trivial. No disrespect intended.


ACK
http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm

Hopefully you aware that you will probably set the wrong time half
of the year.


Actually, the modem appears to ignore the DST setting.


Why would there be such a parameter then?
If I set the date/time to just before the transition date/time, no time
is lost or gained when the clock passes through midnight. [...]


That is not surprising, considering that the standard-to-DST switch (and
vice-versa) does not happen on midnight.
PointedEars
Feb 7 '06 #12

P: n/a
On Tue, 07 Feb 2006 06:39:40 -0000, Jasen Betts <ja***@free.net.nz>
put finger to keyboard and composed:
On 2006-02-06, Franc Zabkar <fz*****@iinternode.on.net> wrote:
Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight.


midnight?


Sorry, brain fart. I tried 2AM and 3AM on the first and last Sundays
of October and the last Sunday of March. There were no DST
corrections.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 7 '06 #13

P: n/a
JRS: In article <4c********************************@4ax.com>, dated
Tue, 7 Feb 2006 18:56:07 remote, seen in news:comp.lang.javascript,
Franc Zabkar <fz*****@iinternode.on.net> posted :
On Tue, 07 Feb 2006 06:39:40 -0000, Jasen Betts <ja***@free.net.nz>
put finger to keyboard and composed:
On 2006-02-06, Franc Zabkar <fz*****@iinternode.on.net> wrote:
Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight.


midnight?


Sorry, brain fart. I tried 2AM and 3AM on the first and last Sundays
of October and the last Sunday of March. There were no DST
corrections.


Those dates are not good matches to existing or future US DST, nor to
what I believe to be the NZ change dates.

But I think you should have got one hit for each location.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Feb 8 '06 #14

P: n/a
JRS: In article <15****************@PointedEars.de>, dated Tue, 7 Feb
2006 08:30:31 remote, seen in news:comp.lang.javascript, Thomas
'PointedEars' Lahn <Po*********@web.de> posted :

That is not surprising, considering that the standard-to-DST switch (and
vice-versa) does not happen on midnight.


The clock change should occur at local midnight Winter Time in the
Azores, and probably in Easternmost Greenland. Granted the OP is not
there, but your statement is dangerously general.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 8 '06 #15

P: n/a
Dr John Stockton wrote:
[...] Thomas 'PointedEars' Lahn [...] posted :
That is not surprising, considering that the standard-to-DST switch (and
vice-versa) does not happen on midnight.


The clock change should occur at local midnight Winter Time in the
Azores, and probably in Easternmost Greenland. Granted the OP is not
there, but your statement is dangerously general.


Fair enough, thanks :)
PointedEars
Feb 8 '06 #16

P: n/a
On Tue, 07 Feb 2006 08:30:31 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> put finger to keyboard and composed:
Franc Zabkar wrote:

Actually, the modem appears to ignore the DST setting.


Why would there be such a parameter then?


I don't know. I also tried 1AM for the "UTC" and "Western European"
time zones, but there were no date corrections there either.

BTW, I used this site as my reference:
http://webexhibits.org/daylightsaving/g.html

As for my modem, it is sold as a modem but it is actually a
modem/router, although the router function is somewhat restricted. In
fact D-Link has a tech note describing how to attach a router to this
modem/router <shrug>. One notable distinction between the DSL-302G
modem and D-Link's other "genuine" routers is that the latter have
configurable firewalls. I suspect the difference is principally in the
firmware. Perhaps the nonfunctional DST parameter is a vestigial piece
of code, ie could it be that the DSL-302G's firmware is a cut down
version of the firmware of a more elaborately optioned model, and that
the DST code has been omitted??? In fact the modem firmware contains
an additional configuration page that has been customised for an OEM
(Optus, my former ISP). Perhaps the DST routine was ditched to make
room for it???

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 8 '06 #17

P: n/a
On Tue, 07 Feb 2006 08:30:31 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> put finger to keyboard and composed:
Franc Zabkar wrote:
http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm
Hopefully you aware that you will probably set the wrong time half
of the year.


Actually, the modem appears to ignore the DST setting.


Why would there be such a parameter then?


On further investigation the modem *does* use the DST setting, but
only when it is configured to sync with an SNTP time server. This
function is essentially undocumented and is accessed via the modem's
telnet interface, not the GUI. The following guide is for a modem with
a similar chipset (Globespan Virata Viking I):

How to use SNTP (Simple Network Time Protocol) to keep the router's
clock accurate:
http://www.sarguide.co.uk/sntp.php

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
Feb 14 '06 #18

This discussion thread is closed

Replies have been disabled for this discussion.