今天是2012年10月21日。这是星期天 但我的VB.NET认为不同:
Debug.Print("Weekday for the date '21.10.2012.'is " & WeekdayName(Weekday("21.10.2012.")))
Debug.Print("Weekday for the date '21/10/2012'is " & WeekdayName(Weekday("21/10/2012")))
Debug.Print("Weekday for the date '" & DateTime.Now.Date & "'is " & WeekdayName(Weekday(DateTime.Now.Date)))
所有这三张支票都给了我:'星期一'平日名称!
如何获得合适的工作日名称?
答案 0 :(得分:8)
这是获取给定日期的工作日名称的正确.NET方法:
Dim myCulture As System.Globalization.CultureInfo = Globalization.CultureInfo.CurrentCulture
Dim dayOfWeek As DayOfWeek = myCulture.Calendar.GetDayOfWeek(Date.Today)
' dayOfWeek.ToString() would return "Sunday" but it's an enum value,
' the correct dayname can be retrieved via DateTimeFormat.
' Following returns "Sonntag" for me since i'm in germany '
Dim dayName As String = myCulture.DateTimeFormat.GetDayName(dayOfWeek)
答案 1 :(得分:0)
#config/routes.rb
resources :forums do
resources :topics
end
#app/models/forum.rb
class Forum < ActiveRecord::Base
has_many :topics
end
#app/models/topic.rb
class Topic < ActiveRecord::Base
belongs_to :forum
end
#app/controllers/forums_controller.rb
class ForumsController < ApplicationController
def show
@forum = Forum.find params[:id]
@topics = @forum.topics
end
end
#app/views/forums/show.html.erb #-> url.com/forums/5
<% @topics.each do |topic| %>
= link_to topic.name, forum_topic_path(@forum.id, topic.id)
<% end %>