Git Product home page Git Product logo

Comments (5)

bvanelli avatar bvanelli commented on August 21, 2024

NTP itself can't handle timezones nor daylight saving times. That's normally the job of the operating system.

What you can do, however, since the daylight savings occur in specific period of time (october 15 to february 17 here) you can just validate the output the DD/MM and adjust the offset accordingly.

Or you can just use the Timezone library.

from ntpclient.

jagganath69 avatar jagganath69 commented on August 21, 2024

I've tried using the TimeOffset parameter in both Constructor and setTimeOffset(). Both does NOT work :(
It still outputs the same time (GMT-2, I think)

from ntpclient.

PeterSek avatar PeterSek commented on August 21, 2024

from ntpclient.

paai avatar paai commented on August 21, 2024

This may help. This function looks for the last sunday of a month and returns the utc. You may refine it for the correct hour that the change occurs.
E.g. here the change is on the last sunday of march and the last sunday of october. Call the function twice for march and october and if the real time falls between the two, it is summer.
BTW: dow() returns day of week as an integer between 0 and 6 inclusive, for the array 'sun','mon', 'tue' etc... weekday() would probably also work, but starts from 1.
Disclaimer: I took this from my code, but cobbled a bit to make it understandable, YMMV.

t=now();
time_t llz=laatstezondag(3,31,year());
time_t hlz=laatstezondag(10,31,year());
if ((t>llz) && (t<hlz)) zomer=1; else zomer=0;

...
time_t laatstezondag(int maand,int dag,int jaar)
{ time_t nu,lz;
char w_dag[4]="xxx";
nu=now();
while ((strcmp(w_dag,"sun")) && (dag>24))
{
setTime(2, 0, 0, dag--, maand, jaar);
strcpy(w_dag,weekdag[dow(now())]);
lz=now();
}
setTime(nu);
return lz;
}

from ntpclient.

WhymustIhaveaname avatar WhymustIhaveaname commented on August 21, 2024

Windows 10 cannot do it either. So, fix it yourself and good luck.

from ntpclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.