1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
-
-
-
-
-
-
- var ds1307 = require('jsupm_ds1307');
-
- var myRTCClockObj = new ds1307.DS1307(0);
-
-
- console.log("Loading the current time... ");
-
- var result = myRTCClockObj.loadTime();
- if (!result)
- {
- console.log("myRTCClockObj.loadTime() failed.");
- process.exit(1);
- }
-
- printTime(myRTCClockObj);
-
-
- console.log("setting the year to 50");
- myRTCClockObj.year = 50;
- myRTCClockObj.setTime();
-
-
- myRTCClockObj.loadTime();
- printTime(myRTCClockObj);
-
- function printTime(RTCObj)
- {
- var timeStr = "The time is: " +
- RTCObj.month + "/" + RTCObj.dayOfMonth + "/" + RTCObj.year + " " +
- RTCObj.hours + ":" + RTCObj.minutes + ":" + RTCObj.seconds;
-
- if (RTCObj.amPmMode)
- timeStr += (RTCObj.pm ? " PM " : " AM ");
-
- console.log(timeStr);
-
- console.log("Clock is in " +
- (RTCObj.amPmMode ? "AM/PM mode" : "24hr mode"));
- }
|