I found an answer that will work for me. In the end, the scope was limited to support this support in the mongo server database and only on Linux.
@ AsyaKamsky pointed to the J / S welcome library, timezone-js , which does full and proper timezone support, given that it uses real-time files from IANA. However, loading arbitrary java-script libraries into the Mongo server environment is not so simple. You can only load global function definitions. timezone-js must also be provided with a custom transport mechanism for loading timezone files (I donβt even know if the MongoDB server environment provides files for access), or timezone files must be precompiled into JSON objects and together with the library. I decided that this was too tedious for the approach, and I would have to be responsible for providing a mechanism for updating timezone files when they were changed.
Another alternative I studied is hacking the J / S implementation used in Mongo to add a function that will do the job that I want to do. This is what I did. In the glibc world, everything is just as gloomy as in JavaScript, but there is a library for work, icu .
I did this patch , which adds the static function Date.daytz (), which, took the UTC timestamp and timezone name, will return the string yyyy-mm-dd.
Given the following display / reduction functions:
fmap = function () { emit(Date.daytz(this.time * 1000, globtz), {count:1}); }; fred = function (k, v) { var r = {count:0}; v.forEach(function (v0) {r.count += v0.count;}); return r; };
I get exactly what I wanted using these two map reduction commands:
{ "mapreduce" : "objects", "map" : fmap, "reduce" : fred, "out" : { "inline" : 1 }, "scope" : { "globtz" : "Europe/London" } }
and
{ "mapreduce" : "objects", "map" : fmap, "reduce" : fred, "out" : { "inline" : 1 }, "scope" : { "globtz" : "America/Los_Angeles" } }