So What If It’s Winter — Montréal Style

Nuit Blanche à MontréalMontréal becomes a city of non-stop festivals at the May Two-Four long weekend — officially Victoria Day except here in Québec where it’s La Journée nationale des Patriotes (National Patriots’ Day). But even through the rest of the year, this city knows how to keep itself entertained. The Montréal High Lights Festival, which culminated with last night’s Nuit blanche, is a case in point among many.

Mark of Mark My Words has posted an excellent set of images of the artwork installed throughout the “Underground City” during this festival. I can’t help thinking how Stephanie and BeeGoddessM would enjoy this event.

As I mentioned in my previous post, I took advantage of the fact the métro was running all night to go out without the car, thereby not having to worry for a change about how many drinks I could have. It was quite amazing to see the métro so busy throughout the night, to the point where I wonder if it wouldn’t be cost-prohibitive to always keep it running around the clock through Friday and Saturday nights. I know that the closure from 1:00 to 5:30 am is meant to allow maintenance, plus the only city to my knowledge that can sustain an all-night subway service is New York City. But it seems to me it could work. I know several people who don’t own a car and whose weekend evening outings have to revolve around night buses and taxis; all-night métro service would certainly be an advantage to them and to someone like me, too.

It was cool to be riding the métro at something like 4:00 am. The only downside is that when I took it from Beaudry to come back home, the westbound train was immobilized in the station. I had also noticed a higher than normal police presence outside the station upon entering. As it turns out, the surveillance cameras picked out some punks who decided to venture into the tunnel between Beaudry and Berri-UQAM. Not only could they have been hit by an oncoming train, but they also risked electrocuting themselves on the high-tension rail.

The wait allowed me to strike up a conversation with two young guys: the short one was from Calgary and is currently studying here in Montréal; the tall one was an Australian who’s visiting cross-Canada from — get this, Damo! — Melbourne. Just previous to Montréal, he had been to Halifax, which he claimed to have enjoyed. I don’t know what would possess him to come to Canada in the dead of winter, but there you have it.

What they didn’t know is that the term nuit blanche, correctly translated, means “sleepless night.” Indeed, literally translated, it would mean “white night.” But the play on words for a winter festival is definitely ingenious.

All this to say that I don’t go out much, especially late at night, but I do enjoy living in a city where there’s no need to fold up the sidewalks at night. That’s certainly the difference with the other cities where I lived.

Il fait beau dans l’métro!

Nouveau métro de MontréalIn early October of last year, after an on-and-off call for bids, the Government of Québec finally announced that it was awarding to Bombardier-Alstom the contract to renew the very aged rolling stock of the Montréal métro. The rolling stock of our métro is among the oldest still in use in the world, some of it dating back to the mid-1960s, but it has been extremely well maintained and upgraded over the years so that it doesn’t really show its age. However, we can only milk so much life out of them, and replacing the stock is by no means a luxury at this point, even though plans are to keep some of the rolling stock in commission until 2017.

I really like the fact that the Société de Transport de Montréal (STM) has called upon the public to choose the exterior colour scheme of the new stock, which should start rolling out in 2014. Even I voted, and the STM announced last week that the scheme pictured above is the one that won by an overwhelming majority. People have more than grown accustomed to the blue of the exterior; they’ve grown to love and “own” it. It’s the colour of our métro and don’t dare take it away! The STM’s next consultation is to come up with a less “technical” name than MRM-10 for the new stock in the hope of coming up with something similar to the city’s wildly successful bicycle rental service, BIXI, a concept that is now being exported to cities around the world and is a coinage from the words “BIcycle” and “taXI.”

It will come as no surprise to you that I prefer Montréal’s métro over Toronto’s subway. Both are almost identical in terms of length and number of stations; although slightly shorter, Montréal’s métro has a significantly higher daily ridership than Toronto’s. But I admit that Toronto’s is better in significant ways, notably wider cars and air conditioning — except that I really despise the fact that Toronto’s is on rails. (Montréal’s is on tires.) Toronto’s is SO noisy when it brakes into a station and, worse, when it takes a curve. And although stations like Bloor-Yonge have been extensively redone over the years, the appearance of Toronto subway stations is still more reminescent of public washrooms. For its part, each station in the Montréal system is different. Some are truly horrific or run down, but at least all attempt to be different, with artistic elements being integrated into the architecture of each. Another significant downside of Montréal’s métro, though, is the very thing I like about it, namely the fact that it IS on tires as well as the overall design of the stock: any extension has to be underground, whereas Toronto’s is and can be more easily expanded above ground outside the city’s central core.

Speaking of expansions, more than a year ago, it was announced that a study to expand three of the four lines of the métro was being undertaken. We were told at the time that the study was NOT to look into the viability of the extensions but into how the extensions were to be done. The blue line will eventually go as far east as it was intended; the yellow will extend deep into the densely populated suburb of Longueuil, and the western branch of the orange line would go a few stations further north of Côte-Vertu, the current terminus. But what kills me, though, is the refusal to look into extending the blue line west of Snowdon into NDG, which is as densely if not more so populated than the extremities of the green line. If the party in power in Québec City were the Parti Québécois, I’d understand that it would be because of petty politics — not wishing to extend into an enclave of les Anglais — but coming from a Liberal government whose power base is the western half of the Island? I really don’t get it.

Tonight is Nuit Blanche, so the métro will exceptionally be operating all night. I think I’ll take advantage of that and go out but not take the car. And perhaps have as much fun on the métro as in this cringe-worthy 1976 promo!

The One Who Said No

Métro de Montréal @ McGillYesterday morning I had to provide the first phase of training for a new client at my day job, and given the size and importance of this new account, most of the training is being done on-site at the client’s workplace rather than by phone or webcast. So, like thousands of other workers, I found myself on the métro heading downtown — orange line from Snowdon to Lionel-Groulx and green line to McGill — which is a major shift from my normal commute from my bedroom, to the bathroom, to the kitchen, and finally to my home office.

It’s toward the end of my journey along the green line that I saw her face, and as I stepped out of the métro at McGill, I’m sure I must have had a grin going ear to ear. One of my very few good memories from high school had come flooding back.

Her face was on an ad for L’École Polytechnique of the Université de Montréal. It was the face of Annie, who is now an associate professor in mechanical engineering at the Poly and is doing research on topics I can bearly understand. But in 1981, she sat behind me in Chemistry 112. And I really liked her.

How much did I like her? Well, Annie is the only girl on the planet whom I ever dared ask on a date.

I still remember my Grade 5 class with Madame Marie at École Essex, specifically the shenanigans going on where the boys and the girls were starting to want to pair up as boyfriend and girlfriend. I say “shenanigans” because I recall that everything had boiled over to the point of an obsession among my peers — except with me, who “inexplicably” (ha ha!) showed no interest in finding myself a girlfriend. As everything had become such a huge distraction in class, Madame Marie put an end to it by declaring, “For heaven’s sake! You’re only in Grade 5! You have a lifetime to find yourselves a girlfriend or a boyfriend. Just take it easy here.”

I took Madame Marie’s admonition to heart and as a sign that THEY — my peers — were the crazy ones and I was the sane one for not obsessing about getting a girlfriend. I stuck to that reasoning for years and I was still holding to it by the time I reached high school. But, of course, what Madame Marie suggested back in Grade 5 wasn’t pertinent anymore by Grade 11, and I realized I had to snap out of that frame of mind.

The thing is, though, that by Grade 11, still wanting to deny to myself that I was gay, I had come to rationalize that I simply needed to find a girl who was really, really smart in order to get me interested. And, in addition to being attractive in her own right and having an easy smile and a propensity to laugh a lot, Annie fit that bill perfectly. So, one evening, out of the blue, I called her and asked her if she’d like to go on a date.

She said no. She already had a boyfriend.

As simplistic and non-sequituresque as it may seem to you, dear readers, that was it for me. Within a very short time after that call, I concluded that if Annie, the only girl in whom I had ever had the remotest interest, wasn’t interested, then I had to face the fact that what I really wanted is to date boys. However, there was one thing that would remain (although I clearly haven’t stuck to it): the object of my affection would have to be really, really smart in order to keep me interested.

It would be tempting to be flip and say that Annie’s rejection is what turned me gay. In fact, I’ve said that a few times as a joke, but of course I have never meant it. She had nothing to do with that, and I don’t believe she has ever known where my thoughts and feelings went after that fateful call. As a matter of fact, that phone call that was such a turning point for me, she probably doesn’t even remember.

And now there she is, on an ad in the métro for L’École Polytechnique of the Université de Montréal — a successful teacher and scientist. I would love to say hello to her and perhaps even tell her this little story. But I think that would be way too weird, especially for her. It goes to show, though, that we all may touch other people’s lives in a pivotal way yet never ever realize having done so.

It Felt Weird Today

I had a horrendously busy day at work today. And I do mean horrendous! Imagine being on the phone almost constantly for 7 hours, stopping just long enough to take a leak and grab another cup of coffee before starting the next call, which like the previous call will last from 1.5 to 2 hours — patiently showing for the 1,000th time a new client how to set up and use an online cash management application. And the voice messages and e-mails cascade in and there’s no time to respond to them until well after what should have been quitting time.

Throughout the day, though, in the back of my mind, I kept remembering that 3 years ago, February 22 fell on a Friday. But I didn’t work that Friday, for a good reason. And 2 years ago, when it fell on a Sunday, I wasn’t even in the country.

I thought 3 years ago that I was beginning a new chapter in my life. And, in fact, I was. I really was. We really were. Except I didn’t think back then that it was going to be such a short chapter. And such a sad one, looking back.

The kicker: He’s so bad at remembering dates that I doubt he thought about it as I did. I could be wrong on that. But I doubt it. I really do.

Time Matters

I had a total lightbulb moment last Friday night and finally arrived at a clever programming feat. And by the time I finished posting this entry, I refined it even more, trimming 5 lines of coding from an already sparse function.

Calendar Snapshot

The above snapshot is that of an application I developed for work, but always with the intention of eventually distributing it. It looks very simple: it’s an online group scheduler. It easily allows a group of people, regardless of their time zone, to see what other members of the group are doing. If I, as a group member, cannot schedule myself for a particular appointment, I can schedule a co-member instead. Pretty straight-forward so far, right?

What you don’t see in this screenshot is that I can change the day view to another time zone. So, say I’m trying to schedule an appointment with someone who is in British Columbia, and the appointment should be at 10:00 am BC time. All I need to do is first switch the time zone pull-down (which you don’t see here) to BC, then click on the plus sign in my column corresponding to 10:00 am BC time to schedule the appointment. Then, when I’m done and I switch back to my time zone in Québec, the appointment will show as being at 1:00 pm, as BC is 3 hours earlier than Québec.

The underlying concept is as follows: Each day is divided into 96 slices, each representing 15 minutes. For me in Québec, Slice 41 represents 1:00 pm but corresponds to 10:00 am in BC. The Eastern time zone is designated as Zone 3 while the Pacific time zone is Zone 6. Most time zones in the northern hemisphere observe Daylight Saving Time at the same time — in North America, Mexico, as usual, is the odd man out in that it starts DST later and ends it sooner, as happens in Europe — so even when the time changes, the 3-hour difference between Zone 3 and Zone 6 stands.

However, there are places like Saskatchewan, where DST is never observed, or the far eastern reaches of Québec’s north shore, which is in the Atlantic time zone (Zone 2 in my scheme) but, since it doesn’t observe DST, is the same time as the rest of Québec when DST is being observed — in other words, Zone 3 in my scheme. In the case of Saskatchewan, the pull-down changes automatically so that this province is listed with Manitoba in winter (Zone 4) but Alberta in summer (Zone 5). As this post from April 2003 attests, I’ve been struggling with the notion of time zones, time differences, and observance and non-observance of DST from many, many years. (In fact, what I wrote 8 years ago about Indiana is no longer true.)

While most of my application relies on PHP’s inherent time zone controls (e.g., for Montréal, putenv(“TZ=America/Montreal”)), each user’s profile also includes the zone number per my group scheduling scheme. And it seemed totally unacceptable — not sufficiently user-centric — to require, as does WordPress (the blogging software I use for aMMusing), those who live and work in one of the unusual time zones to manually switch when we go to and from DST.

To add to the complexity: Most countries in the southern hemisphere do not observe DST, but when they do, they do so in our winter months because it’s summer in their hemisphere. If only it were as simple as, “On the day when we go to DST, they get off DST,” then the programming challenge, while considerable, would be relatively simple. But it’s not that simple.

Take Brazil as an example. Despite its width, most of that country is in one time zone and it observes DST. Right now (February 6, 2011), the time difference between Montréal and Rio is 3 hours, as in, Rio is 3 hours ahead of Montréal. However, towards the end of February, Brazil will cease observing DST and we still won’t be observing it here, so the difference between Montréal and Rio will be 2 hours until mid-March when we will start observing DST, at which point the difference between Montréal and Rio will drop to only 1 hour. On October 16, while we will still be observing DST, Brazil will start observing it as well, so difference will rebecome 2 hours. And finally, when we stop observing DST on November 6, the Montréal/Rio difference will rebecome 3 hours.

Okay, if you followed me this far and think you have it all figured out, I’ll throw Uruguay at you to burst your little bubble. Uruguay is essentially the same time zone as most of Brazil, complete with observance of DST; however, that country’s transition dates are different than Brazil. Instead of ending DST in late February, Uruguay only ends it on March 13, which coincidentally is when we start observing it. And instead of starting it again like Brazil on October 16, Uruguay restarts it October 2 …like the parts of Australia that do observe DST — Australia, which of course, is more than half a day ahead of Uruguay.

So, my challenge was that comparing time differences against Coordinated Universal Time (UTC) was as helpful as tits on a bull. In places where DST is observed, the difference for them is always their basic offset from UTC, that is, X hours or X+1 hours. In other words, in Montréal, we’re either 5 hours behind UTC in winter (i.e., X=–5) or 4 hours behind UTC in summer (i.e., X+1=–4). But for that far northeastern reach of Québec I mentioned earlier, which never observes DST, X=–4 year round, just as for Saskatchewan, X=–6 throughout the year.

The thought of writing hundreds of lines of code upon looking up every exception and hope like hell none ever change brought me close to abandoning any hope of achieving a user-centric script. In fact, I found my first attempt at this fool’s errand didn’t work all the time; Saskatchewan always ended up as a Zone 5 instead of 4 in winter and 5 in summer. That was until it occurred to me that my mistake was to rely on UTC. Instead, I should arbitrarily pick what I consider a “normal” time zone — one in the northern hemisphere that observes DST — compare its offset on any given day against the “target” time zone (i.e., the one whose Zone number I’m trying to find), and adjust that Zone number accordingly.

The result: A 25-line function that I can call from anywhere in my suite of applications (including the group scheduler) and that works 100 per cent of the time! And to illustrate, I’m going to take Alberta (AB), Saskatchewan (SK), and Puerto Rico (PR) as examples of Zone whose number I’m trying to find.

— Regardless of its current offset to UTC, we know that Montréal (Mtl) is always Zone 3 in my calendar scheme.

Time Zone
Date Mtl
Feb 06/11 3
Mar 13/11 3

— Using this function like this, which returns the number of minutes offset between two time zones, start by calculating if Zone 3, synonymous with Montréal, is currently 4 or 5 hours behind UTC.

function get_timezone_offset($the_benchtime, $your_tz, $their_tz = null) {
if(
$their_tz === null) {
if(
!is_string($their_tz = date_default_timezone_get())) {
return
false;
}
}
if (
$the_benchtime == “”) {
$the_benchtime = “now”;
}
$origin_dtz = new DateTimeZone($their_tz);
$your_dtz = new DateTimeZone($your_tz);
$origin_dt = new DateTime($the_benchtime“, $origin_dtz);
$remote_dt = new DateTime($the_benchtime“, $your_dtz);
$offset = $origin_dtz->getOffset($origin_dt)$your_dtz->getOffset($remote_dt);
return
$offset;
}

Having determined that:

$whatdateandtime = “2011-02-06 00:00:00”;
$zone1 = “America/Montreal”;
$zone2 = “UTC”;

…calling the function is as simple as:

$TimeDifference = get_timezone_offset($whatdateandtime, $zone1, $zone2);

And since it gives the value in seconds, where 1 hour has 3600 seconds, convert to hours as follows:

$TimeDifference = $TimeDifference/3600;

So the result is:

Offset from UTC
Date Mtl
Feb 06/11 –5
Mar 13/11 –4

— Then, using the same function, calculate the number of hours the “target” zone (Alberta or Saskatchewan or Puerto Rico) is off compared to UTC.

Offset from UTC
Date Mtl AB SK PR
Feb 06/11 –5 –7 –6 –4
Mar 13/11 –4 –6 –6 –4

— Finally, calculate the target Zone number following this formula:

Base Zone Number — (Target OffsetBase Offset) = Target Zone Number

That formula is part of my “magic” function which refers to (i.e., uses) the function above to get the variable offset numbers.

And remember: Two negatives give one positive, so –7 — –5 is like saying –7 + 5, which is –2, and then 3 — –2 is like saying 3 + 2, which is 5.

Time Zone
Date Mtl AB SK PR
Feb 06/11 3 3 — (–7–5)
3 — –2 = Zone 5
3 — (–6–5)
3 — –1 = Zone 4
3 — (–4–5)
3 — 1 = Zone 2
Mar 13/11 3 3 — (–6–4)
3 — –2 = Zone 5
3 — (–6–4)
3 — –2 = Zone 5
3 — (–4–4)
3 — 0 = Zone 3

Invariably, the result is correct, per my time zone numbering scheme:

Time Zone
Date Mtl AB SK PR
Feb 06/11 3 5 4 2
Mar 13/11 3 5 5 3

Saskatchewan is indeed like Alberta in summer but like Manitoba in winter, and Puerto Rico is indeed like Montréal in summer but like Halifax in winter.

When I’m ready to distribute my script, the purchaser will have to choose one scheduling scheme from the following:

  1. The Americas
  2. Windy City to Kremlin (Americas East to Europe & Africa)
  3. Euroasia & Africa
  4. Asia & Oceania

Essentially, the east/west span is restricted to 10–11 hours. But the same function will always work, even if a scheme spans across the Greenwich line, with the only difference being the base city and its stable Zone number within that scheme:

  1. Montréal
  2. London
  3. London or Paris
  4. Some city in Russia whose DST resembles Europe’s

Or they could be based on Montréal, with only the stable Zone number changing to an improbable yet relational value within the scheme.

A spinoff of coming up with this function is that it brought to my attention that Newfoundland is not the only half-hour time zone in the Americas. Venezuela is the other, but it’s west of Newfoundland and, unlike Newfoundland, never observes DST. So, I was able to adjust the reference table for the Americas in my database and can now assert my application will always work. The cherry on the sundae would be to have a Spanish and Portuguese language file so that it could work in those languages in addition to the current English and French.