I have a timezone name, like "America/New_York" and the year, month, day, hour, minute and second in that timezone, for a particular time. How can I get a timezone aware DateTime object for that time in that timezone. Like a Local object, but with the specified timezone instead of the local timezone.
std::env::set_var("TZ", "America/New_York");
let x = Local.ymd(2019, 12, 1).and_hms(2, 0, 0);
This gives the result that I want, but I don't want to be setting the TZ environment variable because I want Local to remain local time and I need to be able to change the TZ for different cases while chrono only reads the TZ environment variable once, as far as I know.
What I want is something like
let x = ???.tz("America/New_York").ymd(2019, 12, 1).and_hms(2, 0, 0);
That returns a timezone aware DateTime that will handle operations like adding and subtracting durations correctly, given the timezone. So a FixeOffest doesn't work because adding a duration that spans a daylight savings time transition, for example, doesn't (in my experience) yield a result with the correct offset - it stays at the original fixed offset even though that doesn't apply at the new date.
Is there such a thing? Can I make a Local object with a specified TZ without setting the TZ environment variable?