spacetime icon indicating copy to clipboard operation
spacetime copied to clipboard

`spacetime.whereIts` returns an array of timezones names lowercased

Open imns opened this issue 4 years ago • 4 comments

Title pretty much says it all. If I call spacetime.whereIts('4pm') it returns:

[                                                                                                                                                                                                                                                                                                                                                                 
  'america/lima',
  'america/rio_branco',
  'brazil/acre',
  'america/bahia_banderas',
  'america/merida',
  'america/mexico_city',
  'america/monterrey',
  'mexico/general',
  'america/north_dakota',
  'america/chicago',
  'america/knox_in',
  'america/matamoros',
  'america/menominee',
  'america/rainy_river',
  'america/rankin_inlet',
  'america/resolute',
  ...
]

I would expect the timezone names to be in the same format as in the documentation ie: "America/Jamaica" as referenced here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

imns avatar Jun 23 '20 21:06 imns

As a quick/dirty fix I did this, but I'm certain it doesn't cover all the edge cases:

function titleCase(str) {
	return str
		.toLowerCase()
		.split("_")
		.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
		.join("_")
		.replace("Gmt", "GMT");
}
const tzs = spacetime.whereIts("4pm").map((tz) => {
	let [country, region] = tz.split("/");
	return `${titleCase(country)}/${titleCase(region)}`;
});

imns avatar Jun 23 '20 21:06 imns

ah, yeah you're right. I'll add this to the next major.

yeah - there is America/Port-au-Prince and Antarctica/DumontDUrville, and also the GMT ones and things. thanks for the heads-up

spencermountain avatar Jun 24 '20 18:06 spencermountain

Thanks for this great library. 🎉

When can we expect the next release with this resolved?

Great-hijack avatar Feb 22 '22 15:02 Great-hijack

hey @Great-hijack - sorry for the delay on this. Fraid v8 is looking like mid-summer. cheers

spencermountain avatar Feb 22 '22 15:02 spencermountain