Get the first day of the current week

Here is a quick way to get the first day of the current week.

If you are happy with sunday as the first day of the week, then you can simply do this :


 public static DateTime FirstDayOfWeek(this DateTime date)
 {
            return DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
 }

But if you want that the first day of the week matches your culture (eg: the belgian week starts on monday), you have to take care of the culture’s DateTime format.

So the method will change a bit :


public static DateTime FirstDayOfWeek(this DateTime date)
{
     return DateTime.Today.AddDays(-((int)DateTime.Today.DayOfWeek - (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek));
}

Usage :

    DateTime FirstDayOfWeek = DateTime.Today.FirstDayOfWeek();

or

 DateTime FirstDayOfWeek = DateTime.Now.FirstDayOfWeek();

Incoming search terms:

  • asp net get first day of week
  • first day of week in asp net
  • get first day of the week in linq
  • jquery get first day of current week
  • linq how to get the first day of a week
  • net first day of week

JS Mixer is released

CSS mixer is really cool.  Good job.  Is there a JavaScript mixer?

It’s the main content of a mail I received last week.

It decided me to write a JS Mixer application, based on CSS Mixer.
The big part of the work was already done, I just needed to adapt my code.

Just like CSS Mixer, you can download it from codeplex : http://jsmixer.codeplex.com/

You can also download it from some software websites.

JSMixer antivirus scan report at softoxi.com

Remark :

With ASP.NET WebForms, you can achieve the same result by setting a few propertie to the ScriptManager control.

But the advantage to use a tool like JSMixer, is that your server doesn’t have to do the work : it’s already done !

And when you spare some work to your server, your server is happy !

jQuery Performance Tips And Tricks 2011 by Addy Osmani

Addy Osmani has made a nice video presentation about jQuery performance improvement.

jQuery Performance Tips And Tricks 2011 – Addy Osmani from Addy Osmani on Vimeo.

Incoming search terms:

  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1844 35T_b_Y8soGvo4xSAU1m8PjhmoYH-EL8gXWusRngLEHdFQMeOE0gURSS1C0yBk7e 6bb615bbcfdf0ab0af2e0c04c3dd63e3eb4b772c&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1837 AQIKsM1z-IIHRgrdSit6Oy9E-2794VsaBExgNXLHUHJ1zS1TM07INsgm3hDxh1hu f471aefb75ccd71430910741a93bb71303f4e605&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1835 VcuLx9YVKeBdGTjdj4ZYDScMdEkxTatyO9_oVYgX1nPKvKWqAX9FWJFaFnR1G9xw d244038e701ebed06c7939c06c0b44ca39ad6a82&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1834 ORJKY2WNn4HMx2iTDYeP2PeA8UxRPIisdwZKYUQDR-0xxYS3KYKE8XVrlpIAQbDn 88d05d43bef75d89e38b1d07bfd0d50da62c6869&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1832 O7hjo7T38VU-lVoZR9OZqxD3EFwNHJYzcyDA6OtQzjtXvgumst_pxVY_wAo2t3Qq 3fa15e09d7bfc872879f1baddee20b983ccac08d&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1829 NeEMXhn886lV1ejCZybPxODn1YBVJ36DVsnHdPkjh4zy3-ZqU9hVQyj36-8s-9Mc e710992026c328079b8b826130bdfa0e862ff42d&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1828 WicKFHJ2v0w4cnECslAbmPxnzB3EPZgbvwJliLSs4LhIRTuIRgxb3wVJHX_bKOiF c27c2aff8df3b8aa7b9d3efb1f67f76d2cea5766&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1827 jqieuuMeEDc7ck6nMJvWvBeMLgHr6whynSnQDlpGcLHARUp2IPYW5SzLLCGUconM cddfb93cb1f949556c7d172caa1d2da8315633ca&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1825 _IHpN_YPNsVHvQLlhFh7L2arpQovzvuSjQ12qT3Vh3mkzCH51QTO0I4CtqM8okGM 3749c36e72e01b72a50dea38bb3238dbcaca1fc4&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1823 -yE22dmHKbzfwvOsy7LgO_1aDkMVBYZEUDvHuQkIue6CJfD2BRFYnFqr0UTm2uJv aa17f3810abb2ffbbb0011ca25404f4815e096e5&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme