Coder Social home page Coder Social logo

Comments (6)

DrBomb avatar DrBomb commented on May 24, 2024 1

mJS is outside my expertise, I don't use it.

That said, here's your reason https://unix.stackexchange.com/questions/104088/why-does-tz-utc-8-produce-dates-that-are-utc8

Basically the POSIX tz formats are 3 letters plus the offset. But the offset has to be on the opposite sign. Hence why ["sys.tz_spec", "<+05>5"] worked for you. Just use that one.

from mongoose-os.

scaprile avatar scaprile commented on May 24, 2024

May I suggest you go to the forum and search there ? I've answered this at the forum and even have working examples in Spanish

from mongoose-os.

DrBomb avatar DrBomb commented on May 24, 2024

Some questions:

  • How did you read the time shown? Because the SNTP library shows you the unix timestamp on update regardless of your tz_spec value
  • tz_spec only affects a very specific subset of functions. localtime_r is one of them, while other functions like the widely used mg_time() will only return unix time as it should. What are you using?

Time inside C functions, and specially on mongoose can be complicated for begginers. I would suggest, @alnunez, that you make a sample app if you think that indeed, this is a bug on the code.

Good luck!

from mongoose-os.

alnunez avatar alnunez commented on May 24, 2024

Here is the exact piece of code. A function that builds a message, including datetime. Timer.fmt() seems affected by tz_spec, because i tried different values, and all of them changed the time zone when printing timestamp.

function buildMsgUl(){

message_ul.sensor_id=DEVICE_ID;	
let extTemperatureCstr = roundNdigitsTostr(getTempC(),2);
message_ul.temperature_ext=extTemperatureCstr;
let intTemperatureCstr = roundNdigitsTostr((5/9)*(ESP32.temp()-32),2);
message_ul.temperature_int=intTemperatureCstr;	
let batVstr = getBatV();
message_ul.battery=roundNdigitsTostr(batVstr,2);
let timeunix = Timer.now();
let timestamp = Timer.fmt('%Y-%m-%d %H:%M:%S',timeunix);	
message_ul.timestamp = timestamp;

}

from mongoose-os.

alnunez avatar alnunez commented on May 24, 2024

Well after some more experimentation i found some discrepancies in tz for America/Bogota as follows:

from: https://github.com/mamuesp/timezones "America/Bogota":"<-05>5"
This value doesn't work, gave time UTC+5

from: https://github.com/openwisp/netjsonconfig/blob/master/netjsonconfig/backends/openwrt/timezones.py "America/Bogota", "COT5"
This value Works OK as expected (gave time UTC-5 )

from mongoose-os.

alnunez avatar alnunez commented on May 24, 2024

mJS is outside my expertise, I don't use it.

That said, here's your reason https://unix.stackexchange.com/questions/104088/why-does-tz-utc-8-produce-dates-that-are-utc8

Basically the POSIX tz formats are 3 letters plus the offset. But the offset has to be on the opposite sign. Hence why ["sys.tz_spec", "<+05>5"] worked for you. Just use that one.

That's the answer i was looking for! thanks again!

from mongoose-os.

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.