Bogus
Bogus copied to clipboard
Generate random Timezone IDs
Please describe why you are requesting a feature
It would go well with random locale.
Please provide a code example of what you are trying to achieve
var faker = new Bogus.Faker();
faker.Random.RandomTimezoneId();
Expected output: "America/Argentina/San_Juan"
A list of timezone IDs I've found: https://raw.githubusercontent.com/mattjohnsonpint/TimeZoneNames/main/src/TimeZoneNames.DataBuilder/data/zone-precedence.txt
-
Is the feature something that currently cannot be done? No
-
What alternatives have you considered? Randomizing from a list
-
Is this feature request any issues or current problems? No
-
Has the feature been requested in the past? No
If the feature request is approved, would you be willing to submit a PR? No
Some options for this:
- Pulling
tzdata
: https://www.npmjs.com/package/tzdata - Or as a workaround, sourcing the same information from NodaTime:
using NodaTime;
void Main()
{
var faker = new Faker();
var timezones = DateTimeZoneProviders.Tzdb.Ids.ToArray();
var randomTimezones = Enumerable.Range(1, 10)
.Select(_ => faker.PickRandom(timezones));
randomTimezones.Dump();
}