, 20 tweets, 7 min read Read on Twitter
The Twitter API is well documented--and for each endpoint: Standard, 30day, FullArchive. One suggestion: ISO 8601 for dates would be very helpful.
Inspired by @johnnliu, I'm going to attempt my first tweetorial on what to do with weird date patterns like this and how to put it back into ISO 8601 with #MicrosoftFlow.
The first thing I do is look for patterns I can take advantage of.
I notice that the date I receive from my API has spaces between each part. I instantly think, "Oh, that's a delimiter, so let's use split()."
I create a Compose action and write a split() function using the Expression tab. It works just like it does in #PowerApps.

split(body('HTTP')['created_at'],' ')

This means, "Drill into the body of the HTTP action to the created_at field. For each space, split it to a new row."
I output a table where each part of the created_at date time is in its own row.

I can just rearrange it like LEGO blocks now, right? Not yet, I want to format some parts first.
In ISO 8601 convention, the month is a two-digit integer. But with the date I'm given, it's a short month name.
How do I turn "Mar" into "03"? Initial thought might be nested ifs:

if(equals("Mar",...,"03")...

But that's a scary long expression.
Faster way--I find out where Mar is in a string of each month:
indexOf('JanFebMarAprMayJunJulAugSepOctNovDec',outputs('Compose')[1])

Here, outputs('Compose')[1] is the 2nd record in the table of parts of the date. indexOf will return the position where "Mar" begins, which =6.
Each month name is 3 characters long. I want to divide the position by 3, so I can get the month number. So I really want 6 to be 9.

✅ Compensate for how the numbering starts at 0. So add 1.
✅ Compensate +2 to get the end of the month name, not the start of it.

6+1+2=9
So using add() to add 1 and 2, I can then div() by 3 and get the month number.

But ISO 8601 requires two digits for the month. The month number I'm getting is a single digit...
I'd like someone to suggest a better pattern here. I just did an if, "If the month number is less than 10, concatenate a 0." Brute force. It works.

Note: I'll be sharing a flow when I'm done with this, so you can see where I'm going with this.
By the way, I use Parse JSON to create a single record containing the weekday, month, day, etc. It's easier to reference later.

I can reference each row in the split() table from earlier using:
outputs('Compose')[n]

Using Peek Code, here's what I've described so far:
Because I created a single record with all the date's parts, I am ready to rearrange them.

It's as easy as using concat(), then selecting the Dynamic Content in the order I want my date:

concat(year,'-',month,'-',day,'T',time,'Z')
Last step--because I live in Pacific Standard Time, I want the datetime in my time zone. I use convertFromUtc() to do a conversion from UTC to PDT.

Here's a doc on the different time zones:
docs.microsoft.com/en-us/previous…
Here's a gift for you--the flow pattern I used: aka.ms/iso8601

If everyone just used ISO8601, you wouldn't need this :)
#MicrosoftFlow
Big idea:
✅ Split up the date's parts
✅ Reformat any part as needed
✅ Rearrange the parts into ISO 8601
✅ Convert time zone as needed

You can probably smash the flow into 3 steps if needed.
Big thanks to @johnnliu who helped make the flow more efficient for you 🤓
@johnnliu -- I see now that tweeting this spam is much easier than writing a blog.

... Next step is to smash all these tweets into a community blog post or #MicrosoftFlow recipe
I should program @mrflowbot to roll up the thread and draft a blog on my command O_O
#rabbithole
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Mr.Dang(); #JPAUG
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!