waneck / geotools Goto Github PK
View Code? Open in Web Editor NEWDependency-free Haxe geo tools
License: MIT License
Dependency-free Haxe geo tools
License: MIT License
Hey Cauê,
Great work on this little gem!
I'm curious - would some macro magic allow Minutes(12) to be written as 12.minutes for example?
I've just discovered that TzDate.timezone() may return incorrect values due to historical timezone changes.
For example I was testing with Kiribati timezone. And at 01.01.1970 there was different offset then it is now.
Your implementation returns -10:40 hours. Buy todays timezone offset there is +14. Which can be calculated correctly in haxe (but not on all platforms due to makeUtc function):
var d: Date = Date.fromTime(Math.ffloor(Date.now().getTime() / 1000) * 1000); //note ffloor (not floor) to avoid integer overflow
var utcD: Float = DateTools.makeUtc(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
var tzOffset: Float = utcD - d.getTime();
I have not tested for other platforms, but on Neko, calling TzDate.timezone() throws error:
Error : std@date_set_hour
seems that problem is in second argument passed to constructor - it denotes month, and it can't be 0
return - (new Date(1970,00,01 , 00,00,00).getTime() / 1000)
should be:
return - (new Date(1970,01,01 , 00,00,00).getTime() / 1000)
But then, it returns nonsensical value: -2656800
On my computer, I have set timezone UTC +06:00, so it should return -360 minutes, or in seconds it would be -21600.
In the end, I was able to get my desired timezone value from this code:
var a = DateTools.format(Date.fromTime(0), '%H:%M').split(':');
var offset = -Std.parseInt(a[0]) * 60 + Std.parseInt(a[1]);
trace(offset);
edit: on PHP works TzDate.timezone(). Problem is in Neko.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.