Consider this example project where a timezone name needs to be converted to a more readable format.
For instance:
- input:
America/Los_Angeles
- output:
America Los Angeles
While "America/Los_Angeles" may seem human-readable, the requirement is to convert it to a simpler format without slashes or underscores.
This conversion can be easily done with a regular expression, but since moment and moment timezone are used in the project, is there a built-in mechanism in these libraries that can accomplish this?
import 'moment-timezone';
import * as moment from 'moment';
const tz = moment.tz.zone("America/Los_Angeles");
const result = tz.name;
console.log(result); // America/Los_Angeles, need "America Los Angeles"
If relevant, this code is part of an Angular project.