Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Respect users system time preferences as set in the International pre…

…fs [dustin]
  • Loading branch information...
commit b4da17cd0588d92d01e3c04f377f23a17aecd288 1 parent fc4de4e
@Caged authored
View
1  ApplicationController.rb
@@ -10,6 +10,7 @@
require 'osx/cocoa'
require 'mime-types/lib/mime/types'
require 'grit/lib/grit'
+require 'lib/time_extensions'
require 'InfoWindowController'
OSX.ns_import 'CommitSummaryCell'
View
10 CommitsController.rb
@@ -22,8 +22,8 @@ def awakeFromNib
@offset = 50
@active_commit = nil
@icons = Hash.new do |hash, email|
- gravatar = NSURL.URLWithString("http://www.gravatar.com/avatar.php?gravatar_id=#{MD5.hexdigest(email)}&size=36")
- hash[email] = NSImage.alloc.initWithContentsOfURL(gravatar)
+ gravatar = NSURL.URLWithString("http://www.gravatar.com/avatar.php?gravatar_id=#{MD5.hexdigest(email)}&size=36")
+ hash[email] = NSImage.alloc.initWithContentsOfURL(gravatar)
end
if(fetch_git_repository)
@@ -94,7 +94,7 @@ def tableView_objectValueForTableColumn_row(table_view, table_column, row)
objc_method :tableView_willDisplayCell_forTableColumn_row, 'v@:@@@i'
def tableView_willDisplayCell_forTableColumn_row(table_view, cell, table_column, row)
commit = @commits[row]
- cell.subtitle = %(by #{commit.author.name} on #{commit.authored_date.strftime("%A, %b %d, %I:%M %p")})
+ cell.subtitle = %(by #{commit.author.name} on #{commit.authored_date.to_system_time})
cell.gravatarImage = @icons[commit.author.email]
end
@@ -113,9 +113,9 @@ def update_main_document
set_html("hash", active_commit.id)
if Time.now.day == active_commit.authored_date.day
- cdate = active_commit.authored_date.strftime("Today, %I:%M %p")
+ cdate = active_commit.authored_date.to_system_time(:time)
else
- cdate = active_commit.authored_date.strftime("%A, %B %d %I:%M %p")
+ cdate = active_commit.authored_date.to_system_time
end
set_html("date", "#{cdate} by #{active_commit.author.name}")
View
4 GitNub.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 283254680D8B792500D99366 /* lib in Resources */ = {isa = PBXBuildFile; fileRef = 283254650D8B792500D99366 /* lib */; };
285BB47C0D8306C60027980C /* mime-types in Resources */ = {isa = PBXBuildFile; fileRef = 285BB4690D8306C60027980C /* mime-types */; };
285BB5320D849C890027980C /* TexturedWindow.rb in Resources */ = {isa = PBXBuildFile; fileRef = 285BB52F0D849C890027980C /* TexturedWindow.rb */; };
285BB53D0D849DD20027980C /* added.png in Resources */ = {isa = PBXBuildFile; fileRef = 285BB5380D849DD20027980C /* added.png */; };
@@ -61,6 +62,7 @@
/* Begin PBXFileReference section */
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 283254650D8B792500D99366 /* lib */ = {isa = PBXFileReference; lastKnownFileType = folder; path = lib; sourceTree = "<group>"; };
284B71470D7CDE340075DA6C /* nub.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = nub.xcodeproj; path = nub/nub.xcodeproj; sourceTree = "<group>"; };
285BB4690D8306C60027980C /* mime-types */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "mime-types"; sourceTree = "<group>"; };
285BB52F0D849C890027980C /* TexturedWindow.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = TexturedWindow.rb; sourceTree = "<group>"; };
@@ -173,6 +175,7 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
+ 283254650D8B792500D99366 /* lib */,
285BB52F0D849C890027980C /* TexturedWindow.rb */,
285BB4690D8306C60027980C /* mime-types */,
288854540D7E352C00862D67 /* grit */,
@@ -297,6 +300,7 @@
285BB54A0D849EA60027980C /* InfoWindowController.rb in Resources */,
288CB41A0D8789DD0092B5CC /* MainMenu.xib in Resources */,
288CB41D0D878A1C0092B5CC /* Info.xib in Resources */,
+ 283254680D8B792500D99366 /* lib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
14 lib/time_extensions.rb
@@ -0,0 +1,14 @@
+class Time
+ def to_system_time(style = :full)
+ formatter = OSX::NSDateFormatter.alloc.init
+ case style
+ when :full
+ formatter.dateStyle = OSX::NSDateFormatterMediumStyle
+ formatter.timeStyle = OSX::NSDateFormatterShortStyle
+ when :time
+ formatter.dateStyle = OSX::NSDateFormatterNoStyle
+ formatter.timeStyle = OSX::NSDateFormatterShortStyle
+ end
+ formatter.stringFromDate(self.to_ns)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.