Click here to Skip to main content
15,886,072 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Javascript function error. Pin
and180y10-Jun-20 1:55
and180y10-Jun-20 1:55 
GeneralRe: Javascript function error. Pin
and180y10-Jun-20 23:06
and180y10-Jun-20 23:06 
GeneralRe: Javascript function error. Pin
Richard Deeming10-Jun-20 23:30
mveRichard Deeming10-Jun-20 23:30 
GeneralRe: Javascript function error. Pin
and180y10-Jun-20 23:45
and180y10-Jun-20 23:45 
JokeRe: Javascript function error. Pin
DerekT-P11-Jun-20 2:26
professionalDerekT-P11-Jun-20 2:26 
AnswerRe: Javascript function error. Pin
jkirkerx12-Jun-20 7:57
professionaljkirkerx12-Jun-20 7:57 
GeneralRe: Javascript function error. Pin
and180y12-Jun-20 8:33
and180y12-Jun-20 8:33 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 8:47
professionaljkirkerx12-Jun-20 8:47 
Smile | :)
I wrote a similar function for showing that my business is open, based on open and closed hours in TypeScript.
It drove me nuts, was always off by an hour, Daylight savings.
I'll get back to it soon, now that I have more experience in TypeScript.

Frown | :(
setStoreHours(): void {
    const date = new Date();
    const newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
    const offset = date.getTimezoneOffset() / 60;
    this.hourOfDay = date.getHours();
    this.dayOfWeek = date.getDay();
    switch (this.dayOfWeek) {
      case 0:
        // Sunday
        this.storeStatus = "Closed";
        break;
      case 1:
        // Monday
        if (this.hourOfDay > 8 && this.hourOfDay < 17) {
          this.storeStatus = "Open";
        }
        break;
      case 2:
        // Tuesday
        if (this.hourOfDay > 8 && this.hourOfDay < 17) {
          this.storeStatus = "Open";
        }
        break;
      case 3:
        // Wednesday
        if (this.hourOfDay > 8 && this.hourOfDay < 17) {
          this.storeStatus = "Open";
        }
        break;
      case 4:
        // Thursday
        if (this.hourOfDay > 8 && this.hourOfDay < 17) {
          this.storeStatus = "Open";
        }
        break;
      case 5:
        // Friday
        if (this.hourOfDay > 8 && this.hourOfDay < 15) {
          this.storeStatus = "Open";
        }
        break;
      case 6:
        // Saturday
        this.storeStatus = "Closed";
        break;
      default:
        this.storeStatus = "Closed";
    }
  }
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: Javascript function error. Pin
and180y12-Jun-20 10:48
and180y12-Jun-20 10:48 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 11:11
professionaljkirkerx12-Jun-20 11:11 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 10:17
professionaljkirkerx12-Jun-20 10:17 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 5:57
and180y13-Jun-20 5:57 
GeneralRe: Javascript function error. Pin
Richard MacCutchan13-Jun-20 6:31
mveRichard MacCutchan13-Jun-20 6:31 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:48
and180y13-Jun-20 11:48 
GeneralRe: Javascript function error. Pin
jkirkerx13-Jun-20 7:36
professionaljkirkerx13-Jun-20 7:36 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:47
and180y13-Jun-20 11:47 
QuestionJavaScript slide show works bad on the first page load Pin
Hypnonis8-Jun-20 20:03
Hypnonis8-Jun-20 20:03 
AnswerRe: JavaScript slide show works bad on the first page load Pin
Richard Deeming8-Jun-20 22:30
mveRichard Deeming8-Jun-20 22:30 
GeneralRe: JavaScript slide show works bad on the first page load Pin
Hypnonis9-Jun-20 6:33
Hypnonis9-Jun-20 6:33 
QuestionJSON object not showing values.. Can someone help Pin
Member 35640766-Jun-20 4:33
Member 35640766-Jun-20 4:33 
GeneralRe: JSON object not showing values.. Can someone help Pin
Richard MacCutchan7-Jun-20 0:50
mveRichard MacCutchan7-Jun-20 0:50 
QuestionPyramid array Pin
Girardi.E30-May-20 0:48
Girardi.E30-May-20 0:48 
AnswerRe: Pyramid array Pin
Richard MacCutchan30-May-20 1:15
mveRichard MacCutchan30-May-20 1:15 
AnswerRe: Pyramid array Pin
DerekT-P30-May-20 2:30
professionalDerekT-P30-May-20 2:30 
Questionidentify each node with its Id Pin
vikas@prajaktasoftware.com19-May-20 8:57
vikas@prajaktasoftware.com19-May-20 8:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.