jamietr1 / google-docs-writing-tracker

Automation scripts to track writing in Google Docs
187 stars 39 forks source link

formatDate issue #7

Open naalvarez opened 9 years ago

naalvarez commented 9 years ago

When running DailyAlmanac I get this issue:

Cannot find method formatDate(string,string,string). (line 414, file "Code")

I'm also having issues with WritingStats, in that it doesn't seem to correctly capture word counts, either totals or fiction vs nonfiction. I turned Word Count mode on and off to test but there doesn't seem to be a pattern; sometimes it captures the count, sometimes it captures fiction but not nonfiction, sometimes it doesn't capture at all. But I'll keep experimenting and open a new issue if I can't figure it out.

Thanks!

jamietr1 commented 9 years ago

On the first issue, can you add a log line after line 9 like this:

Logger.log(TIME_ZONE);

I want to see what value is being grabbed from your browser for the timezone. That is usually what causes the error in line 414, and I want to make sure this is being handled correctly for all time zones.

naalvarez commented 9 years ago

I'm sorry if I'm just doing this wrong, I'm not a coder by trade.

I added "Logger.log(TIME_ZONE);" on line 9, at the end, and ran the script. I got the same error.

I then deleted "Logger.log(TIME_ZONE);" from line 9, added a new line 10 (thus moving everything down a line) and placed it in the now empty line 10. When I ran the script, I got the same error but for line 415, which makes sense.

But of course, I could just be inputing the code wrong? Sorry!

jamietr1 commented 9 years ago

Sorry, you should get an error. However, once the error happens, go to the View menu and click the Logs... option. This will open a dialog box that will let you see the output of the logging. What I want to see is what your timezone is reporting. Apparently there are some known issues with the formatDate() function and timezones.

The very first thing in the log should be the timezone. It will look something like this:

[14-07-30 12:46:16:204 EDT] America/New_York [14-07-30 12:46:20:632 EDT] Just arrived in getAlamancText() [14-07-30 12:46:21:642 EDT] Set writing goal.

Post what it says, and I'll try to fix it as soon as I can.

naalvarez commented 9 years ago

Then I thought maybe there is an actual LOG you want to see...Just in case, this is the Logging output after adding "Logger.log(TIME_ZONE);" to the end of line 9:

[14-07-30 09:46:59:639 PDT] America/Los_Angeles [14-07-30 09:47:04:992 PDT] Just arrived in getAlamancText() [14-07-30 09:47:05:141 PDT] Set writing goal.

D'oh!

naalvarez commented 9 years ago

Ha! Okay.

jamietr1 commented 9 years ago

Thanks! That's what I need!

jamietr1 commented 9 years ago

I'm narrowing this down, and I think I am close to identifying the issue. I need 2 more things:

  1. What is the last date that shows up in the Date column of your Writing tab?
  2. On the Config tab of the spreadsheet, what is the Offset Days value set to (row 35)?

If the answer to #2 is 1 and the last date showing is 7/30/2014, then that is the problem. Basically, the script looks for the last row and expects to see yesterdays date there. If it doesn't it gets confused. This is something that I definitely need to fix, as it might happen to people who run the Daily Almanac for today instead of yesterday, or if the Daily Almanac runs before the WritingStats has had a chance to run for the current day. I'll add handlers for both those cases.

In the meantime, let me know the answer to those 2 questions above.

naalvarez commented 9 years ago
  1. Since I am currently running the WritingStats script to test it, it does say 7/30/14.
  2. Offset Days is set to 1

Based on what you said, I deleted the 7/30/14 row (I'm currently testing the WritingStats code so it's not important data to keep, I haven't actually worked on my stories just typed nonsense to test) and tried the DailyAlmanac again. I had manually inputed my info for 7/29/14 (that's the only date I have info for, because I actually JUST installed your original script yesterday) and still received the same error. :(

jamietr1 commented 9 years ago

I have fixed this. You have to go in and update the timezone setting in the spreadsheet to match your own timezone (by default, it is set to Eastern, which is my timezone.) That is what was causing the confusion, and the reason you were seeing the formatDate error and I was not. I have added this step to the README.

naalvarez commented 9 years ago

What's weird is that I'm in Eastern timezone, as well...I just double-checked, and the spreadsheet is indeed set to Eastern.

I went ahead and updated the code regardless, just replaced it all with the new code you published a few minutes ago for DailyAlmanac. Added my spreadsheet ID, and now I get the same error a few lines down.

Cannot find method formatDate(string,string,string).(line 433, file "Code")

jamietr1 commented 9 years ago

In the log you sent, the timezone was showing up as "America/Los_Angeles". That value has to match the value of the spreadsheet. I can think of 2 possible solutions, both of which should work:

  1. Check the time zone on your computer and browser to make sure it is set to Eastern time. The call that the script uses (Session.getTimeZone()) takes its value from your browser session, which in turn typically gets it from your computer. If that doesn't seem to be the issue (if your browser and computer are set to Eastern time) then... 2. Change the time zone setting in the spreadsheet to Pacific and that should make the error go away.

Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Wed, Jul 30, 2014 at 3:29 PM, naalvarez notifications@github.com wrote:

What's weird is that I'm in Eastern timezone, as well...I just double-checked, and the spreadsheet is indeed set to Eastern.

I went ahead and updated the code regardless, just replaced it all with the new code you published a few minutes ago for DailyAlmanac. Added my spreadsheet ID, and now I get the same error a few lines down.

Cannot find method formatDate(string,string,string).(line 433, file "Code")

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50667221 .

naalvarez commented 9 years ago

Voila! Problem solved!!

But I actually did something a little different - before changing the spreadsheet settings, I checked the code project properties (File-->Project Properties) for both DailyAlmanac and WritingStats - BOTH were set to Pacific Time for some reason, even though the spreadsheet was automatically set to Eastern.

So I changed both to Eastern and tried to run DailyAlmanac again - same issue. But I copied the code from github one more time and replaced everything in DailyAlmanac again, double checked project was set to Eastern, and ran it - this time it worked! Got a Daily Almanac email at last!

If that didn't work I was going to change everything to Pacific. But it got me thinking and there you go.

I did notice that the Writing Summary states I wrote a "total of undefined words." But I remember seeing something similar in another thread so I assume it is being worked on.

Thank you so much! I'm SO excited to start using this! Thanks for publishing this and updating it!

jamietr1 commented 9 years ago

Good call on checking the timezone of the scripts also. I'll add a note to the README for that.

I know what is causing the undefined problem and should have it fixed this evening.


Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Wed, Jul 30, 2014 at 4:12 PM, naalvarez notifications@github.com wrote:

Voila! Problem solved!!

But I actually did something a little different - before changing the spreadsheet settings, I checked the code project properties (File-->Project Properties) for both DailyAlmanac and WritingStats - BOTH were set to Pacific Time for some reason, even though the spreadsheet was automatically set to Eastern.

So I changed both to Eastern and tried to run DailyAlmanac again - same issue. But I copied the code from github one more time and replaced everything in DailyAlmanac again, double checked project was set to Eastern, and ran it - this time it worked! Got a Daily Almanac email at last!

If that didn't work I was going to change everything to Pacific. But it got me thinking and there you go.

I did notice that the Writing Summary states I wrote a "total of undefined words." But I remember seeing something similar in another thread so I assume it is being worked on.

Thank you so much! I'm SO excited to start using this! Thanks for publishing this and updating it!

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50672735 .

naalvarez commented 9 years ago

Thank you so much!! Really appreciate it!

naalvarez commented 9 years ago

Well I've just updated the DailyAlmanac to the latest code - I saw it was updated late last night - and the issue has returned. Now it is line 435, but still the same error code.

This is what the log says (I added the log code to line 9 again): [14-07-31 08:58:47:067 EDT] America/New_York [14-07-31 08:58:50:775 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:776 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:777 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:777 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:778 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:779 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:779 EDT] Range [14-07-31 08:58:51:070 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:071 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:072 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:073 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:074 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:074 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:075 EDT] Range

I've checked, the spreadsheet and both code files are set to (GMT-05:00) Eastern Time. I'll tried changing the timezone for the DailyAlmanac in both directions but had the same issue.

So I actually deleted the entire file, and created a brand new DailyAlmanac, checking time zone settings and everything. Same issue on line 435.

Log now says: [14-07-31 09:12:25:755 EDT] America/New_York [14-07-31 09:12:29:109 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:109 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:110 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:111 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:112 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:113 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:113 EDT] Range [14-07-31 09:12:29:333 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:334 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:335 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:335 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:336 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:336 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:337 EDT] Range

I even tried it in a different browser but same issue, and my computer is definitely set to Eastern.

But Issue 8 with the word count seems to be fixed! I'll go update there...

Sorry for the trouble!

jamietr1 commented 9 years ago

Hmm? There is at least some forward progress. The dates are lining up correctly, which means the time zone setting are right. Is line 435 the line that is actually throwing the error? Can you send the exact error message you are getting, because based on the logs, it looks like 435 is working. Also, can you let me know are you running the Almanac with the offset set to 0 or 1?


Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Thu, Jul 31, 2014 at 9:15 AM, naalvarez notifications@github.com wrote:

Well I've just updated the DailyAlmanac to the latest code - I saw it was updated late last night - and the issue has returned. Now it is line 435, but still the same error code.

This is what the log says (I added the log code to line 9 again): [14-07-31 08:58:47:067 EDT] America/New_York [14-07-31 08:58:50:775 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:776 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:777 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:777 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:778 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:779 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:50:779 EDT] Range [14-07-31 08:58:51:070 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:071 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:072 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:073 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:074 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:074 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 08:58:51:075 EDT] Range

I've checked, the spreadsheet and both code files are set to (GMT-05:00) Eastern Time. I'll tried changing the timezone for the DailyAlmanac in both directions but had the same issue.

So I actually deleted the entire file, and created a brand new DailyAlmanac, checking time zone settings and everything. Same issue on line 435.

Log now says: [14-07-31 09:12:25:755 EDT] America/New_York [14-07-31 09:12:29:109 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:109 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:110 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:111 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:112 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:113 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:113 EDT] Range [14-07-31 09:12:29:333 EDT] 10/30/2013 <-> Wed Oct 30 2013 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:334 EDT] 03/11/2014 <-> Tue Mar 11 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:335 EDT] 07/27/2014 <-> Sun Jul 27 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:335 EDT] 07/28/2014 <-> Mon Jul 28 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:336 EDT] 07/29/2014 <-> Tue Jul 29 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:336 EDT] 07/30/2014 <-> Wed Jul 30 2014 00:00:00 GMT-0400 (EDT) [14-07-31 09:12:29:337 EDT] Range

I even tried it in a different browser but same issue, and my computer is definitely set to Eastern.

But Issue 8 with the word count seems to be fixed! I'll go update there...

Sorry for the trouble!

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50756593 .

naalvarez commented 9 years ago

The exact error is:

Cannot find method formatDate(string,string,string). (line 435, file "Code")

The Offset Days is set to 1, and the last date is 7/30/14.

Is it odd that my documents are set to (GMT-05:00) Eastern Time, but the log shows GMT-0400 (EDT)? Quick research shows that EST SHOULD be -04:00...not until we set our clocks back in November will it be GMT-05:00. Could that be the issue?

I tried to find a way to adjust Google Drive timezone settings, but other than individual documents I couldn't find a way. I switched back to the Old Drive (I was working in the "New" Drive) to see if that was the culprit, and got the same error, even when I created a new DailyAlmanac file again. I'll research to see if there's another way to change the GoogleDrive time zone to be more specific. There IS a way in settings, but again it says GMT-05:00 Eastern.

jamietr1 commented 9 years ago

No, DST is not the issue. I see the same thing on my end, but it works for me. I suspect this is a red herring for something else. It is almost as if the script thinks you have one extra row in your spreadsheet and that row is being treated as blank. A null date would cause a problem with the function call.

One thing to try would be this. Delete all of the blank rows that come after the last record on the Writing tab. When the script runs at night, it will add new rows automatically as necessary, but doing this will help identify if there is a "phantom" row in your spreadsheet that might be gumming up the works.


Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Thu, Jul 31, 2014 at 9:48 AM, naalvarez notifications@github.com wrote:

The exact error is:

Cannot find method formatDate(string,string,string). (line 435, file "Code")

The Offset Days is set to 1, and the last date is 7/30/14.

Is it odd that my documents are set to (GMT-05:00) Eastern Time, but the log shows GMT-0400 (EDT)? Quick research shows that EST SHOULD be -04:00...not until we set our clocks back in November will it be GMT-05:00. Could that be the issue?

I tried to find a way to adjust Google Drive timezone settings, but other than individual documents I couldn't find a way. I switched back to the Old Drive (I was working in the "New" Drive) to see if that was the culprit, and got the same error, even when I created a new DailyAlmanac file again. I'll research to see if there's another way to change the GoogleDrive time zone to be more specific. There IS a way in settings, but again it says GMT-05:00 Eastern.

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50760561 .

naalvarez commented 9 years ago

Sadly that didn't fix it, I deleted all the rows after 7/30/14 and ran DailyAlmanac again, same issue.

naalvarez commented 9 years ago

I don't know why I thought to do this...but in the Writing Tracker spreadsheet, in the Config tab, I noticed that line 39:Include Blogging was set to 1, and the notes say if set to 1 it will report blog stats to Daily Almanac. On a whim I changed it to 0, tried DailyAlmanac again, and it worked.

To be sure, I changed it back to 1 - error line 435. Changed it to 0 - no error, DailyAlamanac successfully delivered to my email.

I think I read that this version doesn't update blog stats yet? Could that be it then? I'll just leave it on 0 for now!

As an FYI, changing Include Blogging to 0 Also allowed the Records and Data tabs to update successfully in the Writing Data spreadsheet - until now nothing had ever changed there, so I assumed it was a placeholder for later versions.

Thanks again!

iomadh commented 9 years ago

I had this issue - it is related to the Blogging section not being used you need to update the config and set Blogging to 0

jamietr1 commented 9 years ago

Duh! I know what 's happen now. Good catch @naalvarez and @iomadh. I'll update the code to prevent this condition.

jamietr1 commented 9 years ago

Specifically, it was trying to grab the word count for blogging and there are null values on your blogging spreadsheet. So I need to protect against those.

jamietr1 commented 9 years ago

I modified the shared spreadsheet to default the Include Blogging to 0 which should prevent the error that way. I am also trying to trap the exception that arises in above when there are no dates on the spreadsheet and report that error more clearly.

Merovex commented 9 years ago

Just kibbutzing...I believe Google is using your IP location to detect timezone. Or, it's picking it up from your workstation. I'm Eastern, but when I was in Pacific on a trip, everything adjusted to Pacific.

Easiest way around that (should it not be a red herring) is to baseline on GMT.

On Thu, Jul 31, 2014 at 10:53 AM, Jamie Todd Rubin <notifications@github.com

wrote:

I modified the shared spreadsheet to default the Include Blogging to 0 which should prevent the error that way. I am also trying to trap the exception that arises in above when there are no dates on the spreadsheet and report that error more clearly.

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50769830 .

Ben Wilson "A belief, no matter how sincere, if not reflected in reality isn’t a belief; it’s a delusion."

jamietr1 commented 9 years ago

Turns out it was a red herring. The call was failing because it was getting a null date value for one of the parameters. That said, according to the Google Apps Script documentation, the Session.getTimeZone() call takes the TZ from your browser session.


Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Thu, Jul 31, 2014 at 12:43 PM, Merovex notifications@github.com wrote:

Just kibbutzing...I believe Google is using your IP location to detect timezone. Or, it's picking it up from your workstation. I'm Eastern, but when I was in Pacific on a trip, everything adjusted to Pacific.

Easiest way around that (should it not be a red herring) is to baseline on GMT.

On Thu, Jul 31, 2014 at 10:53 AM, Jamie Todd Rubin < notifications@github.com

wrote:

I modified the shared spreadsheet to default the Include Blogging to 0 which should prevent the error that way. I am also trying to trap the exception that arises in above when there are no dates on the spreadsheet and report that error more clearly.

— Reply to this email directly or view it on GitHub < https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50769830>

.

Ben Wilson "A belief, no matter how sincere, if not reflected in reality isn’t a belief; it’s a delusion."

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50785222 .

rlabanti commented 9 years ago

I modified the shared spreadsheet to default the Include Blogging to 0 which should prevent the error that way.

Eventually, GWT_Settings_1.png need an update.

rlabanti commented 9 years ago

With the version of yesterday morning (CEST) something went wrong in a different line:

8/2/14 12:49 AM getAlamancText Cannot find method formatDate(string,string,string). (line 455, file "Code") time-based 8/2/14 12:49 AM

I will try tonight the actual version.

digitalnotions commented 9 years ago

I sorted out the issue I was having. Turns out that I had failed somehow to set the default timezone in the spreadsheet to PDT. Therefore, the daily almanac script was computing incorrect dates for all rows in the writing tab.

jamietr1 commented 9 years ago

I've seen that error most often when both the Timezone setting on the spreadsheet and the scripts don't match.


Jamie Todd Rubin (@jamietr http://twitter.com/jamietr) http://www.jamietoddrubin.com http://www.jamietoddrubin.com/going-paperless/

On Sat, Aug 2, 2014 at 12:07 PM, rlabanti notifications@github.com wrote:

With the version of yesterday morning (CEST) something went wrong in a different line:

8/2/14 12:49 AM getAlamancText Cannot find method formatDate(string,string,string). (line 455, file "Code") time-based 8/2/14 12:49 AM

I will try tonight the actual version.

— Reply to this email directly or view it on GitHub https://github.com/jamietr1/google-docs-writing-tracker/issues/7#issuecomment-50966758 .

rlabanti commented 9 years ago

Unfortunately don't seem the case. Any suggestion for a debug?

rlabanti commented 9 years ago

Perhaps resolved; I will try this night

ndandanda commented 9 years ago

I have the same error in line 512 of the DailyAlmanac script: Cannot find method formatDate(string,string,string). (line 512, file "Code").

Both scripts are set to GMT+1. Triggers: getDailyWordCount 9PM-10PM, getAlmancText 11PM - Midnight

Offset days: 0

Thank you!

katychuang commented 9 years ago

I too had this error, and looked up the documentation for formatDate(). It doesn't take 3 string types but rather a date and two strings: formatDate(Date,string,string).

To fix quickly:

Inside function findDate(value, range){}, change the line that starts with var curDate to make the first a Date type like so ...

// Change this
var curDate = Utilities.formatDate(data[i][j], TIME_ZONE, "MM/dd/yyyy");
// to this
var temp = new Date(data[i][j]);
var curDate = Utilities.formatDate(temp, TIME_ZONE, "MM/dd/yyyy");

Also where TIME_ZONE is set should be updated to var TIME_ZONE = Session.getScriptTimeZone(); as the previous Session.getTimeZone() is deprecated.

rustuptwist commented 9 years ago

I had some similar problems as I am in Asia time zone but for some reasons all of my sheets had the same timezone selected but google was still giving me an error. I changed them all to (strangely enough) Tehran which is +:30 minutes more than my time zone and I stopped getting the TZ error. I then received the 'formatDate(string,string,string)' error and used @katychuang 's suggestions and the error 'seems' to have disappeared. We will see tomorrow when the scripts posts my writing for today, assuming I get some done. Cheers